All Questions
13,697
questions
0
votes
1
answer
15
views
gvim often give this error: E8backupdir=~/.vim/tmps failed to start the GUI
I often log in remotely to a specific server using ssh -X from a Macbook Pro terminal instance. When I use gvim then usually I get a local Xwindow and can edit normally while the terminal session ...
0
votes
1
answer
15
views
Using variable to find & replace while incrementing number with regex
Given the following text:
0 : Container(
alignment: Alignment.center,
padding: const EdgeInsets.all(24.0),
child: RichText(
text: TextSpan(
...
0
votes
1
answer
38
views
Alt > or Alt < mappings do not work
I am trying to configure the key mappings for the barbar plugin commands, specifically the BufferMovePrevious and BufferMoveNext actions. The desired key combinations are Alt < and Alt >. ...
0
votes
1
answer
15
views
Is it possible to have NERDTree open file in a selected window?
Suppose I have 4 split windows with window number 1 the file explorer and window number 2-4 different file buffers. Can I have NERDTree open a new file in a selected window, say window number 4? I ...
0
votes
1
answer
37
views
NeoVim: Following the insturctions in ":h clipboard-wsl" not work? It shows "no provider" but also "ok" in ":checkhealth"?
I am using neovim on archlinux/WSL2, and try to communicate with the Windows clipboard in neovim.
Following the instructions in :h clipboard-wsl, I filled in init.lua with code:
vim.g.clipboard = {
...
0
votes
1
answer
196
views
Useful script to manage buffer and window?
I want to create a vertical split from current buffer for reference another file/the same file. After I've done with this split I don't want to see this buffer-for-reference in the split, but:
If ...
0
votes
4
answers
50
views
Mapping: Automatic placement of cursor into (<>) when I press <space> twice
For my Latex setup in VIM I want to map different text modules where the cursor is automatic placed in between (<>), when I press twice <space> and when the cursor arrives there the (<&...
42
votes
5
answers
9k
views
How do you “chomp” a string in Vim?
Suppose you run the following piece of vimscript:
let @z = system("date")
This will put a string version of the current date into the z register, but the string will end with a newline that I don’t ...
1
vote
1
answer
33
views
How to show the current statusline definition?
I want to see the current statusline definition/string as loaded by Vim. So, taking into account :help statusline, if it is the default, the output would be empty, but if ruler is set (and nothing ...
1
vote
1
answer
451
views
neovim lsp configuration
I'm a begginer in vim/neovim world.
I understand that lsp is for autocompletion, auto import, signature info, etc...
So I have installed coc.nvim.
But I have some question about the concept :
if I ...
26
votes
11
answers
16k
views
Quickly calculate the total of a column of numbers
I'm writing down a markdown table which looks like this:
| 13/05/15 | 09:30-16:00 | 6.5 |
| 14/05/15 | 10:00-16:30 | 6.5 |
| 16/05/15 | 15:30-01:00 | 9.5 |
| 21/05/15 | 09:00-16:30 | 7.5 |
| 22/...
1
vote
1
answer
199
views
Whats the difference between k and C-p?
Is there any difference between the behaviour of C-p and k? The seam to be doing the same thing; moving up a line
-1
votes
2
answers
31
views
Prevent <c-w>q to quit Vim when there is only one window left
I wish to close windows and wipe out the associated buffers with <c-w>q but at the same time I want to prevent to quit Vim when there is only one window left.
My attempt is as follows:
...
0
votes
1
answer
26
views
How do I position cursor according to filetype (gitcommit)?
Sometimes on start, the cursor is not at the top in gitcommit buffers. I assume that this is because it wasn't on the first line the last time I exited a gitcommit buffer and the position was saved in ...
2
votes
3
answers
45
views
Can we configure Vim tag following to be more intelligent?
In large code bases, there can be multiple hits for an identifier. Sometimes dozens. When you look up a tag, the first choice in the list is often some false positive you don't want.
The user ...
-1
votes
0
answers
42
views
How do I add the fugitive commands to which-key?
How do I add things like ]c, ]m, etc. to which-key.nvim's menu?
I think I need to register these in some kind of on-attach script?
2
votes
2
answers
29
views
Command to set the window width
Using MacVim, I can manually drag the edge of the window (watching the numbers in the title bar) to whatever width I want.
Is there a command that will just immediately set it to a desired width? I ...
1
vote
3
answers
103
views
How to efficiently highlight a region given a START and END position expressed as line_nr, col_nr?
Say that I want to highlight a region expressed in terms of two coordinates of the form (line, column), e.g. C1 = (l1, c1) to C2 = (l2, c2).
I read :h matchaddpos() but it seems that you can only ...
0
votes
1
answer
18
views
How to remove paths starting with a certain pattern from a list of paths?
Say that I have the following list:
vim9script
g:my_paths = ['C:\Users\myname\Miniconda3\envs\myenv',
'C:\Users\myname\Miniconda3\envs\myenv\python310.zip',
'C\Mypath',
'C\Anotherpath',
'C:\Users\...
0
votes
1
answer
31
views
'scrolloff' in insert-mode completion menu (like in vertical command-line completion)?
I just realized that vim's completion list could be a bit nicer to use if it mimicked the vertical-style command-line completion menu (wildoptions=pum), which gives some scrolloff.
This lets the user ...
26
votes
3
answers
4k
views
Is there search and replace history in Vim?
We can retrieve search and replace history on IDEs and text editors.
Likewise is there a search history or a way to retrieve previously searched expression in Vim?
0
votes
1
answer
102
views
Recommended way to run vimscript normal commands with lua
What is the recommended way to run VimScript normal commands in Neovim with Lua?
Sometimes, I can achieve things very easily with a few keypresses executed as a normal command compared to scripting ...
3
votes
1
answer
68
views
Is it possible to keep a swap file but disable the auto-recovery mechanism?
I want to have swap files for manual inspection if needed, i.e. I don't want ViM to ask me every time I have a swap file if I want to recover / edit, etc. but I do want to have the option to manually ...
3
votes
1
answer
314
views
How do I perform a code action on a visual range in Neovim 0.9?
In Neovim 0.8, I had the following command mapped
vnoremap <leader>a :lua vim.lsp.buf.range_code_action()<cr>
which in visual mode, gave me options such as Wrap In Try-Catch/Extract Method ...
0
votes
1
answer
36
views
How to automatically close all the terminal buffers when closing vim with :qa?
I am wondering if there is a way to automatically force-wipe all the running terminals when quitting Vim with :qa.
My attempt (that does not work):
vim9script
def WipeoutTerminals()
for buf_nr in ...
1
vote
2
answers
70
views
Why `highlight X ...` from `.vimrc` does not work in gVim (but works in VIM) and I have to type it again during session?
For following snippet of code, to see what was highlighted I need to run :highlight LineHighlight ctermbg=darkgray guibg=drakgray after running vim session, and then rest of snippet works (i.e. loads ...
0
votes
1
answer
23
views
Pattern works with / but it does not work when used in filter function()
I want to extract the the substring Python 3.11 from the strings like Python 3.11.2.release0 (i.e. I want to extract Python followed by the first two digits separated by a .). Such longer strings ...
0
votes
0
answers
15
views
ALE lints but does not fix
I have ALE configured to lint and fix Ruby and Javascript files. Linting works as expected - the tools are found and I get info in the location list, etc. about changes to be made.
However, fixing the ...
6
votes
2
answers
6k
views
Vim terminal: How to split below by default?
Opening the vim terminal using :term, 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?
I know I can ...
1
vote
1
answer
66
views
Show index of tabs in the tabline
I want when i type :tabnew , that it automatically create numbered (indexed) tabs according to which tab in order it is.
if it's 3rd tab that will be opened, than to show number 3 before tab name ( 3 [...
79
votes
10
answers
125k
views
How can I change the font size in gVim?
Is there a way to change the size of the font in gVim, using native commands?
And if not, what script can be used to do it quickly?
1
vote
1
answer
81
views
How to handle no content for a custom text object?
I am building custom text object in lua. With the following code, I am able to change content within certain symbols. This is my code:
local in_symbol = function(start_symbol, end_symbol, mode)
...
0
votes
0
answers
10
views
How to autoformat with efm-langserver
I just want autoformat on save, I don't want it to have any delay.
And they say efm-langserver is best choice.
After I installed via AUR yay -S efm-langserver, that's only I know what to do.
How do I ...
1
vote
1
answer
64
views
Vim also deletes the line under the selected region -- why?
To delete multiple lines, I highlight a line with Shift v. And then go down a few lines and press d.
When I do this, Vim deletes the selected lines and the line directly below it.
I am not sure what ...
0
votes
1
answer
477
views
Highlight nvim tree directory that contains file I found with telescope
Is there a way to highlight a directory of a found file?
For example I look for a specific file with telescope and when I open it, my nvim-tree is updated and shows me parent directory?
-1
votes
1
answer
51
views
How can make the expansion to take effect in any type of file?
If I add the following lines in html.snippets:
snippet "(\S+)(\d+)" "Repeat token n times" r
`!p snip.rv = int(match.group(2)) * match.group(1)`
endsnippet
#5 can expand to #####.
...
1
vote
1
answer
28
views
Neovim append method does not works on matchpairs
I want to append <:> to vim.opt.matchpairs, which AFAIK is a string type.
Neovim lua doc says:
vim.opt:append()
Option:append(value)
...
1
vote
1
answer
146
views
YouCompleteMe messages truncated
I'm using YouCompleteMe for syntax checking, and long error messages at the bottom of the screen are truncated. How can I view the full message?
0
votes
1
answer
61
views
Stop flushing the last command when hitting enter
Suppose I wrote this command:
command! -nargs=1 E echo ' -> <args>'
and when user feeds an argument,
:E abc
I intend to see the following effect as they hit Enter:
:E abc -> abc
Of ...
0
votes
1
answer
79
views
How to range format with nvim 0.9.0?
I don't set a mapping to format code because it is not something I do all the time. So previously, I used to have a command to format or range format as follows:
" format code
command! -range ...
0
votes
2
answers
29
views
Misunderstanding of interaction between local options, moving between windows, and WinLeave, WinEnter, BufLeave, BufEnter events
This what is logged in :messages when I'm printing the value of nu and rnu upon the 4 events WinLeave, WinEnter, BufLeave, BufEnter during the action, done twice, of opening :help and closing it. The ...
0
votes
2
answers
94
views
Syntax highlighting with only some allowed colours
In my ubuntu gnome-terminal I have vims default syntax highlighting color scheme + some color-tuning made in my gnome-terminal to filter out most colors with green except red, purple and brown. ...
1
vote
1
answer
34
views
Is there any way to automatically adjust OS specific environment variables, path, etc. format?
Often in my scripts I have some ugly snippets like the following:
vim9script
var bin = ""
if has("win32")
bin = "\\bin"
else
bin = "/bin"
endif
g:...
0
votes
1
answer
16
views
How to change the internal vim python sys.path?
I have learned that py3eval('print(sys.path)') return the sys.path used internally by Vim.
Say that i want add a new_path to the current sys.path. How shall I do?
I would appreciate solutions that ...
-2
votes
0
answers
35
views
Detect the key pressed [closed]
I am using vim/gvim 7.4 and I am looking in docs and searching from Google, but I cannot find an answer to the following question.
Is there a way to capture the key I just typed (i.e. digit, a ...
1
vote
2
answers
92
views
LeftMouse focus window without moving cursor
Is there a way for clicking on a Vim window to focus that window if inactive (without moving the cursor), then move the cursor if the window is already active?
Here's what I've got so far:
function ...
10
votes
2
answers
2k
views
Visual scrolling/visual <C-e> and <C-y> across wrapped lines?
This has been asked on stackoverflow before, but it seems it still has no solution. Perhaps that has changed with Vim 8.0.
I'd like to be able to scroll (i.e. scroll-wheel, or <C-y>/<C-e> ...
1
vote
1
answer
20
views
Export environment variable to Vimspector
I have some env vars set-up in my .bashrc but when I'm running Vimspector, those variables are not set-up. I want to export the env var when staring Vimspector, but I haven't managed to figure out how....
0
votes
1
answer
553
views
Syntax highlighting not working in Vim when containerized in Docker
I am running an instance of Vim in a Docker container, with configuration mostly taken from here (up untill " Build debug and release targets...)
As you can see on the pic, clangd-completer works ...
0
votes
2
answers
71
views
netrw :Sex and :Vex clear the current buffer
If I open a file in Vim and then run :Vex (or :Sex) it opens netrw in both the new split and the existing split. This happens even if I have unsaved changes, meaning the changes are lost.
The ...