Error with modeline: "E12: Command not allowed from exrc/vimrc in current dir or tag search"
Hi, I have a file with the name xxx.css.mw (I edit MediaWiki file locally), actually this is CSS file, the last line:
> / vim: set syntax=css: /
On file opening I see this:
"User:Vitaly_Zdanevich%2Fglobal.css.mw" 488L, 10099B
Error detected while processing modelines[488]..Syntax Autocommands for "*"..function <SNR>3_SynSet[25]..script /home/vitaly/.vim/pack/git-submodules-plugins/start/vim-css-color/after/syntax/css.vim[1]..function css
_color#init[10]..css_color#enable:
line 3:
E12: Command not allowed from exrc/vimrc in current dir or tag search: ^Iaugroup CSSColor
line 4:
E12: Command not allowed from exrc/vimrc in current dir or tag search: ^I^Iautocmd! * <buffer>
line 8:
E12: Command not allowed from exrc/vimrc in current dir or tag search: ^I^I^Iautocmd CursorMoved,CursorMovedI <buffer> call s:parse_screen() | call s:create_matches()
line 9:
E12: Command not allowed from exrc/vimrc in current dir or tag search: ^I^I^Iautocmd BufWinEnter <buffer> call s:create_matches()
line 10:
E12: Command not allowed from exrc/vimrc in current dir or tag search: ^I^I^Iautocmd BufWinLeave <buffer> call s:clear_matches()
line 12:
E12: Command not allowed from exrc/vimrc in current dir or tag search: ^I^Iautocmd ColorScheme <buffer> call css_color#reinit()
line 13:
E12: Command not allowed from exrc/vimrc in current dir or tag search: ^Iaugroup END
line 15:
"User:Vitaly_Zdanevich%2Fglobal.css.mw" 488L, 10099B
Press ENTER or type command to continue
is there a way to copy the second or third word in vim on a given row, can you also copy multiple different lines?
is there a way to copy the second or third word in vim on a given row, can you also copy multiple different lines?
https://redd.it/1agcizj
@r_vim
Any crazy people here swap j and k?
Just wondering if anyone else has the weird preexisting muscle memory where they want J to be up and K to be down. When using Vim I tend to shift my right hand to the left by one space so my four fingers are all on the nav keys. So I want up to be on my middle finger for some reason. Maybe it's my brain taking WASD's middle finger W up and putting that on my right hand, but J up just seems so much more natural. Anyone else have this?
https://redd.it/1ag104a
@r_vim
of the earlier items from the list for <i>
is specified, then .
is used implicitly. As such, all of the following are equivalent. (Be careful of sub-expressions being negative, since vim might error out depending on how close you are to the top of the file. Also note that a final calculation of line 0 is typically interpreted as line 1.)
- +
- ++-
- +2-1
- .+
- .++-
- .+2-1
If the ends of a range are backwards (the end is before the start), vim will ask you if you would like to reverse the order.
#### Putting It All Together
A sample of what a complete range might look like is 7;/apple//carrot/+37-22++-,'t+7/the/+6
. This starts on line 7, searches for the next line with "apple," then the next line with "carrot," then goes 37 lines down, 22 lines up, 1 line down, 1 line down, 1 line up (this is the beginning of the range). Now it goes back to line 7 (because of the ,
, though this doesn't matter because of the mark), goes to the line with mark t
, then goes 7 lines down, searches for the next line with "the," and goes 6 lines down (this is the end of the range).
#### How Do You Use the Range?
A good chunk of commands accept a range. This is denoted in the helpdocs by :[range]...
. A few examples of commands which support a range are :d
, :y
, :>
, :<
, :s
, :g
, :norm
. For example, :7,'z >
indents the lines in the range starting at line 7 and ending at the line with mark z
(note that the space between the range and the command is optional, so :7,'z>
is equally valid).
#### Automatic Ranges
If you are in visual mode and hit :
, it will automatically generate a range which acts upon the lines your selection touches ('<,'>
). Note that if you are pairing this with something like :s
and want to strictly stay within the selection (instead of line-wise), you must put \%V
at the start (and potentially end) of your pattern (:h \%V
). Additionally, if you are in normal mode and type some count followed by :
, it will automatically generate a range which acts upon count
lines (with the range starting at the current line; .
for 1, .,.+9
for 10, etc).
---
For more information about ranges, you can look into :h [range]
, :h :range
, and :h 10.3
.
---
Previous (Week #7)
https://redd.it/1afkii7
@r_vim
Looking for a good text editor for Windows that uses Vim
I'm looking for a lightweight text editor that I can use Vim in. I often take small notes outside of my primary notetaking programs like Evernote and Obsidian, and for that I usually use Notepad++.
I've recently wanted to start using Vim in more and more situations to help learn it further, but Notepad++ doesn't seem to have a Vim mode.
Now, I know what most people might say: N++ doesn't have a Vim mode because Vim is a different type of editor than N++ is, and without things like multiple buffers, Vim isn't really useful.
Well, for starters, I'd happily use a general notetaking app for Windows that perfectly simulated Vim and allowed buffers, saving and reading text files to a custom location.
With that said, I'm also happy to just use a "Vim-lite" setup like how Obsidian's Vim mode works. Basically, it's all of the Vim commands that can realistically work inside of another program. So yeah, no buffers or anything, but that's fine because Obsidian already has shortcuts to open blank pages, put two pages side-by-side on the same screen, etc., and they all work perfectly fine while in Vim mode. Sure, I'd love for the Vim keybindings for that stuff to work, but my thought is that any practice is better than none.
https://redd.it/1afatab
@r_vim
Vim motions for programing
I stared using Vim mode on my editor, trying to gradually change way I approach a code.
Is there any cheatsheet or page where people explain chain of commands/keys they use for specific task, for example chain of keys to change first arg of XXX method, etc
https://redd.it/1aekzik
@r_vim
Configuration work with ansible yml files
It seems to me that vim is actively trying to not get the indentation correct on nearly every single thing I do when I work with yml files. It's truly horrible.
Does anyone have a nice configuration snippet for my .vimrc file that makes it great to work with yml files?
https://redd.it/1ae41gz
@r_vim
General usage of Quickfix list with errorformat
Hey guys,
I have a basic notion of the Quickfix list and already used it for some :[vim]grep
stuff in combination with :cdo
. But when it comes to :make
, I have the odd feeling I am missing something, so now, I am here.
I have multiple questions and python will serve as background example (for the first one).
1. When using the errorformat='%C\ %.%#,%A\ \ File\ \"%f\"\\,\ line\ %l%.%#,%Z%[%^\ ]%\\@=%m'
, taken from :h errorformat-multi-line
, :clist
and :copen
omit different outputs – Why?. In the screenshot below, you can see both, :copen
on top of :clist
:
https://preview.redd.it/d11o1e2qqdfc1.png?width=672&format=png&auto=webp&s=24ef43ec41d52602c3a2d62041aa5907a6782794
I wonder in gerneral why incorporates :copen
the first line of the error message? I can use:cnext
, etc. without problems but this looks quite weird and I guess it's me using errorformat
and :make
not appropriately. I experienced the gears of Vim working neatlessly in any situation.
2. Why aren't multi line error messages so hard (ie. impossible) to process using `errorformat`? I searched the internet and found some results on this topic but all claiming you shouldnt do it. This render the whole concept redundant, not at least for python but for all languages having multi line error messages, doesn't it?
3. How do you use the Quickfix list? I am especially interested for :make
contexts but open for everything.
Thank you for your answers and examples! :)
https://redd.it/1adveo5
@r_vim
WTF some guys line numbers in videos?
Lot of videos guys have line numbers counting up from current line both in both up and down direction.
How?
Why the fuck?
https://redd.it/1adqbx0
@r_vim
NERDTree and log: I need to see in the tree, text that start with or for hierarchical order.
Hey! I want to use vim for journaling/personal log. My notes are going to be in a folder named "2024" with each month as a separate txt file.
In each monthly .txt file, I'll get my entries with a format like this, using and for hierarchical order:
* SUNDAY 28 --> the date of each daily entry
Did thing A --> a short description of something interesting
Did thing B --> a short description of something interesting
Thing A happened.
A long and detailed description of thing A.
Thing B happened.
A long and detailed description of the thing B.
* MONDAY 29
... another entry with the same format.
The idea is to see ON THE TREE the date and the short description of the most important things (thing A and thing B) that happened that day under the date. If I hit ENTER on any of the date or the description, it shows the full entry for that thing on the right window.
Can something like this be done? Please don't make me go to Emacs.
Thanks!
https://redd.it/1ad6ejv
@r_vim
How to make vim not do anything when using ci( if the cursor is not between parenthesis?
Example text:
testa (testb) testc
testa
and one does ci(
or cib
in normal mode, then vim, at least on my computer, changes testb. That is, it changes the first encountered text between parentheses after the cursor position. This does not seem to work if the cursor is at testc.ci(
if the cursor is not surrounded by parentheses?I need your suggestions
I am 17 year old college freshman. I have used Vscode and Windows my entire life. I am transitioning from Windows to Linux at the moment and am considering continuing coding in terminal with a command line text editor rather than Vscode.
People suggested me Vim/Neovim, I don't know the difference between the two. A lot of my coding work will be based around Python, Java, C/C++. Web development langauges might be later on. Would Vim/Neovim be ideal for me? I am using Fedora 39. Plus I heard many plugins need to be installed to optimise Vim/Neovim for each of these languages, so where do i get these? Will I be able to work on all above mentioned langauges in Vim/Neovim?
Is there any extensive video lecture/course kind of material or any article out there to help me get started and get going? Would be really grateful for your support 🙏 I am ready to put in the hardwork, and do what it takes .
Thank you in advance!!
https://redd.it/1ad619y
@r_vim
change inner anything
Is there a plugin or some vim commands that could help binding a key sequence to change the text between any "surround character" regardless of whether it is ',",(,, or {.
There could be some edge nested cases like `( kind of "complicated " scenario)` but these are rare for me and I am ok with undoing whatever happens in those cases.
[https://redd.it/1ad7uif
@r_vim
Weekly tips/tricks #4
Welcome back! This week, I will cover moving the cursor around the current line and scrolling the current line to different parts of the current window.
Sorry for the delay on this post; I was a bit busy these past few days due to the holidays. I aim to continue having these posts be during the weekends, where possible.
---
# Moving Around the Current Line
#### These are fundamental to getting to different parts of the current line. (These also make explaining the next section simpler.)
- 0
moves cursor to first character in line
- ^
moves cursor to first non-blank character in line
- $
moves cursor to last character of line
- g_
moves cursor to last non-blank character in line
- gM
moves cursor to the character in the middle of the line
- |
moves cursor to the count
th character in the current line
#### These are related to wrapped lines (if you have this enabled 1). These effectively treat each wrapped part of a single line as separate lines.
- g0
moves cursor to first character in wrapped line
- g^
moves cursor to first non-blank character in wrapped line
- g$
moves cursor to last character of wrapped line
- gm
moves cursor to the character as close as possible to the middle of the current window (on the current wrapped line)
- gj
moves cursor down to the next wrapped line (like j
, but treats wrapped lines as separate lines)
- gk
moves cursor up to the previous wrapped line (like k
, but treats wrapped lines as separate lines)
More information on these can be found in :h left-right-motions
and :h up-down-motions
.
[1]: I like using set wrap
, set linebreak
, and set display+=lastline
together.
---
# Scrolling Current Line
### Oftentimes, it can be useful to move the current line the cursor is on to a different portion of the window (top/middle/bottom) to see some important information surrounding it.
- zt
scrolls current line to the top of the current window
- zz
scrolls current line to the middle of the current window
- zb
scrolls current line to the bottom of the current window
- z<CR>
same as zt^
- z.
same as zz^
- z-
same as zb^
For more information, you can look at :h scroll-cursor
.
---
Previous (Week #3)
https://redd.it/18x7fn2
@r_vim
unmap dd
i find that i lean on the d key and inadvertently delete many lines before i even notice (my hands rest always on the home row). I would like to unmap this and change it to D because i don't use D at all. How should i go about it? This is the best info i have found re how to unmap dd: https://unix.stackexchange.com/questions/180926/disable-or-remove-default-vim-keybinding ie use nop. Before i do any such thing i wanted to ask if this makes sense, it seems to me it would be safer at least. Thanks
https://redd.it/18wvlp6
@r_vim
:Lexplore
not opening new file in current directory view
Hey,
Looking at docs i don't see any reason why :Lexplore
won't create new file in current directory that I'm in like :Explore
.
step to reproduce:
1. open netrw
2. navigate to a directory
3. press %
and see file is created in current buffer directory not where i was in netrw
even changing netrw_keepdir
to 0 doesn't make netrw to behave sane.
Edit: I meant "creating new file" in title.
https://redd.it/1agcdkz
@r_vim
[plugin] A tool to backport NeoVim colorscemes to Vim
https://github.com/skywind3000/vim-color-export
https://redd.it/1ag7arn
@r_vim
I printed my VIM cheat sheet. I hope it is in some way useful for you. 🤓
https://redd.it/1afqn9c
@r_vim
Weekly tips/tricks #8
This week, I will be covering ranges, which are a relatively simple, yet fundamental (and surprisingly versatile) aspect of vim.
---
# Ranges
#### The General Format
The basic format of a range is <1>,<2>,<3>,...,<n-1>,<n>
, where <i>
is something which refers to some line. It is important to note that, while this is a valid format, only the last 2 (<n-1>
and <n>
) are looked at; the rest get "ignored" (not exactly, but this will be further explained below). As such, the standard syntax is either of the form <1>
or <1>,<2>
, where <1>
specifies the start of the range, and <2>
specifies the end of the range. (If the range is of the form <1>
, then the range effectively starts and ends on the same line.)
There is an alternative syntax of the form <1>;<2>;<3>;...;<n-1>;<n>
. The delimiter ;
sets the position of the cursor (internally while processing the range) to that of where <i-1>
ends up, whereas each <i>
with the ,
delimiter calculates from the current cursor position. This means that each <i>
affects the calculation of the next! This opens a lot of options for making very involved ranges. For example, :/a/;/a/;/a/;/a/ d
deletes all lines within the range starting at the 3rd line with an "a" beneath the current line and ending at the 4th line with an "a" beneath the current line. I have not yet explained what /a/
means, but that will come soon; I just wanted to give a little hint as to why I called ranges "surprisingly versatile."
At this point, you might be wondering whether you can mix ,
and ;
. The answer is yes! The general rule of thumb is that ,
keeps the cursor on the same line as it was previously at, while ;
moves the cursor to that of where the previous <i-1>
ended up. As such, :/a/;/a/;/a/,/a/ d
(equivalently, :/a/;/a/;/a/; d
) is the same as my earlier example, except it makes the range go from the 3rd line with an "a" beneath the current line to itself (it's a range over 1 line).
#### Line Number Syntax
Now that I have covered the basic format, let's get into the meat of ranges. The items below are of a single, arbitrary <i>
from the format I specified earlier.
- <NUMBER>
specifies the <NUMBER>
th line absolutely (the first line in the file is 1
, for example)
- $
specifies the last line in the file
- .
specifies the current line (note how ;
from earlier changes what is considered the current line)
- %
specifies the entire file (it is equivalent to 1,$
)
- '<MARK>
specifies the position of <MARK>
(case sensitive; uppercase ones only work if they are in the current file), i.e. 'a
- /<PATTERN>/
specifies the next line which has a match for <PATTERN>
in it
- ?<PATTERN>?
specifies the previous line which has a match for <PATTERN>
in it
- \/
specifies the next line which has a match for the most recently used <PATTERN>
- \?
specifies the previous line which has a match for the most recently used <PATTERN>
- \&
specifies the next line which has a match for the most recently used <SUBSTITUTE_PATTERN>
(from :s, etc.
)
Note that you can actually have more than one pattern in the same <i>
with the format /<PATTERN_1>//<PATTERN_2>/.../<PATTERN_N>/
. Each pattern searches for the matching line after the previous pattern's matching line, which can be useful if you want to reset the overall cursor position after all of this (i.e. /a//b//c/,/a/
, which will make a backwards range since the last /a/
uses the initial current cursor position, which matches where the first /a/
was). Additionally, you can have a mark prior to all this, so 'm/apple//banana/
is valid.
#### Offsets
Each of the earlier items can have 0 or more of any of the following appended (in any combination).
- +
means next line
- +<NUMBER>
means <NUMBER>
lines down
- -
means previous line
- -<NUMBER>
means <NUMBER>
lines up
The combination of a mark with multiple patterns as a single <i>
can have the offsets put at any spot between them (such as 'm+2/apple/-1
).
Note that if none
How my cat made me appreciate VIM
I'm a VSCode user who uses Vim when VSCode gets too annoying. While I am programming at home, my cat frequently sleeps on my lap. This is great -- until my legs go from being completely numb to being numb and hurting somehow, and it's especially not great when my cat is grumpy (usually from lack of treats). Because when she is grumpy and I try to reach over to my mouse, she goes straight for my radial artery. Thus, trapped by my cat, I am forced to abandon the mouse and stick to the keyboard -- the keyboard, which allows me to edit text without moving my arms much or reaching about. Confined to the beautiful keyboard by my angry cat. That is how my cat made me appreciate Vim. Before Vim, my arms were shredded. After Vim, my cat sleeps happily.
TL;DR my cat bites me when I try to reach for my mouse, so Vim came to the rescue
https://redd.it/1af3kew
@r_vim
I guess it's time to upgrade the water dispenser at work
https://redd.it/1ae596v
@r_vim
Can I set the text color when syntax is off?
Sometimes i like to turn syntax off, but i'd like to be able to change the color off the text to orange or green.
Is this possible?
https://redd.it/1adwiw8
@r_vim
How to break a line in normal mode
In vim if iam already in normal mode the only way to open anewline is by pressing o/O. But i want to break a line in the current postion like
"Hello world"
to
"Hello
World"
https://redd.it/1adsqak
@r_vim
Vim Source Control Management, upstream branches status monitoring
Sup Everyone,
I'm refreshing my config trying to have most of the things I often use in my workflow.
One thing I really 'miss' from VSCode is the Source Control Management features.
ie I could see all the checked out branches and, if one of my colleagues merged something in development, the 'development' branch would show up as red in the 'branches' section as a reminder I had to pull it and rebase my current feature branch
Is there a way to achieve the same using fugitive.vim or some other plugin?
Like a constant monitoring of upstream and some visual feedback when something changed on those and requires action.
I hope I managed to explain what I mean, cause googling it so far didn't have much success (probably just my grug brain)
Thank you fellas <3
https://redd.it/1ad22x8
@r_vim
Vim default clipboard paste behaivor question
For the last 15 years I have been using vi/vim as a default editor. I would like to ask all of you vim power users and other vim ninjas to explain me why vim deviated that much from its original track, at least in related to pasting some text from clipboard and what is the point behind these decisions and project development?
First, it took me several years to addopt vim instead of vi, and i switch to vim due to syntax highlighting.
Now, I cannot explain how frustrating is to connect to different systems and before text editing i must change vim config or type commands like: set nopaste/paste(always forget which of these two i must pick), mouse=+-r...a...in order to select/mark some text (which would save that selection to clipboard) and paste that text with middle click mouse button into vim insert mode...
I am open-minded so I would immediatelly accept suggestions which are logic...so please change my mind.
https://redd.it/1ad1ard
@r_vim
Yank contents of a line excluding leading white space?
Here is a common pattern of mine to move to the first no blank character, select the rest of the line and yank:
_v$y
Is there a quicker way to achieve this?
https://redd.it/1acxwr7
@r_vim
Do you use s key?
I've been using Vim for 3 years, and since the beginning, I mapped s to something else.
Now I'm on my way back to de-customizing my vimrc and staying as vanilla as possible.
I'd like to restore the original s functionality, but seriously, I don't find it useful at all.
As for S, I always use cc or C as I need.
Concerning s, I usually use xi or cl, but anyway, I rarely get into insert mode this way.
So the question is, can you enlighten me on how to begin using s in a useful way?
https://redd.it/18xm1jj
@r_vim
Vim 9.1 released
https://www.vim.org/vim-9.1-released.php
https://redd.it/18wxq4r
@r_vim
Modifying Quickfix behaviour to not to showing <filename>|<line> for each ocurrence?
I have been dipping my toes on QuickFix functionality in vim , which is great. And I have a use case for my notes.
Getting straight to the point , I am just using a quick fix in the following way
vimgrep /(X)/ %
cheatsheet.vim.not|673 col 71-74| |BufReadCmd| before starting to edit a new buffer |Cmd-event| (X)
cheatsheet.vim.not|675 col 65-68| |FileReadPre| before reading a file with a ":read" command (X)
cheatsheet.vim.not|676 col 66-69| |FileReadPost| after reading a file with a ":read" command (X)
|BufReadCmd| before starting to edit a new buffer |Cmd-event| (X)
|FileReadPre| before reading a file with a ":read" command (X)
|FileReadPost| after reading a file with a ":read" command (X)