Strange behaviour of popup windows in command mode
So I had an idea for using popup windows from command mode. I've struggled for a few days with this. While I now believe I've stumpled upon a solution, I wanted to ask if somebody knows a better way.
Say that I want to make `<c-k>` open a popup with some text. I tried to do that using:
function! MyPop()
call popup_create(['Here is some text', 'and here is some more'], {})
endfunction
cnoremap <c-k> <cmd>call MyPop()<cr>
The above didn't quite work. When I hit `<c-k>` nothing happens at first. The popup would only appear when I leave command mode by hitting `<esc>` or when I first open `wildmenu` and then accept an item from `wildmenu`. If I instead call `popup_create` from normal mode or any other mode then it would work just fine. So one thing I tried is to use `win_execute` to call `popup_create` from the context of a window which isn't cmdline with command mode. But that didn't work either. Eventually I tried the following:
function! MyPop()
call popup_create(['Here is some text', 'and here is some more'], {})
redraw
endfunction
cnoremap <c-k> <cmd>call MyPop()<cr>
Now this works just like expected. When I'm in cmdline and hit `<c-k>` the popup appear instantly. But I think it's a bit odd that I have to keep track of which mode I'm in when I try to open a popup window and then call `redraw` depending on which mode I'm in. So I wonder, is there a way to do this without having to add the extra call to `redraw`?
https://redd.it/18wqbxe
@r_vim
VIM unresponsive, usually while editing Latex files
I use the Apple provided vim on a MacBook, and every time I use it to edit Latex files, it becomes unresponsive. It works for 2 minutes maybe, and then most keypresses are ignored. Has someone met a similar problem with vim?
I have syntax highlighting turned off, not sure what causes it.
It seems to be an issue with .tex files, so I suspect it is trying to parse tex or something, but no idea how and why, and how to turn it off.
% vim --version
VIM - Vi IMproved 9.0 (2022 Jun 28, compiled Nov 12 2023 01:16:04)
macOS version - arm64
Included patches: 1-2018
Compiled by root@apple.com
I don't have any plugins loaded, other some installed by Apple by default:
:scriptnames
1: /usr/share/vim/vimrc
2: ~/.vimrc
3: /usr/share/vim/vim90/plugin/getscriptPlugin.vim
4: /usr/share/vim/vim90/plugin/gzip.vim
5: /usr/share/vim/vim90/plugin/logiPat.vim
6: /usr/share/vim/vim90/plugin/manpager.vim
7: /usr/share/vim/vim90/plugin/matchparen.vim
8: /usr/share/vim/vim90/plugin/netrwPlugin.vim
9: /usr/share/vim/vim90/plugin/rrhelper.vim
10: /usr/share/vim/vim90/plugin/spellfile.vim
11: /usr/share/vim/vim90/plugin/tarPlugin.vim
12: /usr/share/vim/vim90/plugin/tohtml.vim
13: /usr/share/vim/vim90/plugin/vimballPlugin.vim
14: /usr/share/vim/vim90/plugin/zipPlugin.vim
​
https://redd.it/18wqpzu
@r_vim
How can I make Vim take up the entire area of the Windows terminal?
When opening Vim, for some reason it does not occupy the entire terminal area, and there are quite large terminal background frames around it.
Can this be fixed and how to do it?
​
https://preview.redd.it/763wr2acr0ac1.png?width=1415&format=png&auto=webp&s=950e48c8b7160d619f5d5d53a987f1c79f55fc72
https://redd.it/18wo5oz
@r_vim
What is "set clipboard=unnamed " for? (in vimrc)
Hi, I was seeing how install vim-plug in Win and the Ytuber put his vimrc with this set: set clipboard=unnamed
what is it for?
thank you and Regards!
https://redd.it/18sqoyi
@r_vim
If you are Writter of txt (not programmer) and using Win os you can shut down matchparents
**Hi**
If you don't want matching parents "(" and ")" you shoud take off the build in plugin matchparent of the list of plugins of vim.
this is why if you put in _vimrc *set no showmatch* it is ignored.
Thank you and regards!
https://redd.it/18tkiqb
@r_vim
What VIM feature is this?
Not sure what this feature at the bottom is, so I can disable it. Can anyone help identify it please, I've never seen this before.
Thanks in advance for your help!
https://preview.redd.it/noplppfzuy9c1.png?width=1195&format=png&auto=webp&s=7e4c6723f0c2fc19d384c337ecd0a241478fec27
https://redd.it/18wi676
@r_vim
Vim installation went well but the installation of YouCompleteMe did not. Had to reinstall python, and ran "source ~/.zshrc" to get YouCompleteMe to install. I am getting these errors. Anybody familiar on what could be causing them or how to resolve them?
https://redd.it/18te9aq
@r_vim
How to keep variable in `:execute` as what it is
def Default(options: dict<any>)
for [opt, val] in items(options)
if !exists(opt)
execute opt .. $" = '{val}'"
endif
endfor
enddef
Default({
"g:plug_config_autoload": 1,
"g:plug_config_dir": expand("~/.vim/config"),
"g:plug_config_edit_command": "edit",
})
Hello, everyone.
I want to set `g:` global variable inside a dictionary. The problem is if I set as above, the value of `g:plug_config_autoload` will become `"1"` and not `1`. So if I test with `if g:plug_config_autoload` I will get an error.
How can I set variable correctly without care about their type?
Thank you.
https://redd.it/18uaypv
@r_vim
Best mapping for <Space><Space>?
<Space><Space> (or <Leader><Space> in my case) is one of the simplest key combinations to type. What would you use this for? Feel free to include any plugin you like.
I just experimented with map <Leader><space> <Plug>(easymotion-lineanywhere)
(but I think I want to change the mapping to something else)
https://redd.it/18wbgk2
@r_vim
Go to definition within multiple includes
So I have a struct called SDL_Surface which I don't know where i can look for, I know that it is not in SDL.h but maybe it is in one of the header files included in SDL.h, now how do I look for it while having SDL.h in current buffer?
https://redd.it/18uds6x
@r_vim
Static code analysis?
I am back to work on some hobby Arduino/STM32 project and ofc I can't remember everything I learned about C/C++ and Vim (senility issue?). :D
I am using platformio and I have Yegappan LSP installed with clangd which, even if it reports some non-existing errors (the code builds anyway and I am fine with these few errors), I can't remember if LSP also offer Static Code Analysis features - but apparently it does not.
I remember back in years I was using cppcheck along with ALE but I was not using any LSP. As 2023, does anyone have any suggested way to integrate a static code analyzer like cppcheck in Vim? I would like a tidy solution, so far I have the impression that ALE became a huge plugin.
​
https://redd.it/18ujbk3
@r_vim
Vim removes the current line on first input - can someone help?
It's been a few weeks ago that I tried to modify the tab indent for yaml files to two spaces.
Since then every time I open a file in vim, it removes the current line as soon as I touch a key except ESC (even arrow keys).
After it removed the line, vim is in insert mode.
I undid my changes (at least I think so) but the behavior persists.
I've already un-installed vim from the machine and reinstalled it (twice - once removing my users vim related files as well).
Nothing helped so far. Dos anyone have an idea how I can fix this?
https://redd.it/18w2jub
@r_vim
index finger J or middle finger J in normal mode?
When I first started using vim, I would shift my right hand one key to the left so my four fingers matches hjkl
(middle finger j
), but eventually I find that to be slow and confusing, since I need constantly think about which keys my fingers are on when switching between insert and normal mode.
I tried remapping hjkl
to jkl;
, but that causes problems in visual mode, and ;
doesn't seem to work sometimes. In general, using original mapping probably makes using un-configed vim, and vim extensions on other IDE easier as well.
So I changed back to hjkl
, but now I don't shift my hand, instead I reach with my index finger every time when pressing h
(index finger j
). This feels less confusing for me, but the stretch is not very ergonomic and comfortable, and my ring finger gets tired more quickly than my pinky (I think this is because I can use the power of my wrist when using pinky, or maybe I my pinky is just strong).
How do you do it? index finger j
or middle finger j
or remap? And how should I do It?
https://redd.it/18vzjzt
@r_vim
vim tutorial in react
Hey everyone, I want to make a simple vim tutorial in react do you know some good resources on the subject ? A repo with a basic [edit\] working vim [/edit\] implementation or something I could use ?
Thanks a lot
https://redd.it/18vb2m7
@r_vim
Tip: Ctrl+Ins is a quick way to yank to system clipboard
I noticed that on gvim for Windows that `Ctrl`+`Ins` copies (yanks), which goes nicely with `Shift`+`Ins` for pasting from the system clipboard and a lot quicker than `"+y`.
(if you didn't know, these keyboard shortcuts are part of the [IBM Common User Access (CUA)](https://en.wikipedia.org/wiki/IBM_Common_User_Access) of 1987)
I made this mapping so that it also works on Linux vim/nvim/gvim and vim for Windows (terminal version) as well.
Sorry, I don't have a Macbook to hand, so I don't know if this is possible on Macs.
" Ctrl+Ins to yank to system clipboard
" like with gvim for Windows (quicker)
if has('unix') || has('win32') && !has('gui_running')
vnoremap <C-Insert> "+y
endif
`Shift`+`Del` for Cutting doesn't work and there is no point as it's two keys when `x` or `d` is just one.
https://redd.it/18vansb
@r_vim
Project
How does one actually create a project once I’m set up for Java development? I can create a file and start coding but I get the “main.java is a non project file”. I’m sure this has been answered before but I’m not seeing an answer that I understand. Sorry I’m new to text editors.
https://redd.it/18wrb5s
@r_vim
A non controversial Vim video, as all things should be. Bye!
https://www.youtube.com/watch?v=Vq8h8bb6VmY
https://redd.it/18wpdfm
@r_vim
who installed airline with patched font for Δ in Vim for Win?
Hi!
I'd like to know if anyone could install the Δ of any patched font for airline in Vim for terminal cmd.exe (not for gVim) on Windows.
Thank you and Regard!
https://redd.it/18szd5l
@r_vim
Simple example request on using setqflist() getqflist()
Hi ,
Can anyone provide an example of how to manually create a QuickFix list? meaning manually by using the functions setqflist() getqflist() , say for a simple example :vimgrep /(X)/ %
Providing that
" setqflist({list} [, {action} [, {what}]]) *setqflist()*
" getqflist([{what}]) *getqflist()*
client coc abnormal exit err when using nvm and older nodejs version in project directory
So I use COC (yes I know this is r/vim) and today I had to use an older version of nodejs to follow a tutorial which is a bit old and uses node v12.19.
I used nvm to get the older nodejs version going on and coc throws this error when I open vim in any directory.client coc abnormal exit
1
has anyone else encountered this issue and is there a way to tell coc to use the system-wide installation of nodejs instead of whatever nvm is doing?
ps:
vim version 9 on arch
edit:
after running nvm deactivate
everything is back to normal
https://redd.it/18tbi98
@r_vim
Reverse insert not working on mac
Doesn't work on vim via terminal or Alacritty, but strangely works on MacVim.
:set revins
:set ri
anyone else with this problem? or figured out what's wrong?
https://redd.it/18tbqju
@r_vim
where is there anything like "complete"?
Hi, I was writting and I touched any keys and a pop up appeared given me a pair of words related to the first letters I write.
what build in plugin of gvim on Win is related to it?
I din't install any autocomplete plugin at all.
this is the list of autolad built in plugin of vim on Win: https://imgbox.com/uWKqVryy
Or what will be that keys I pressed for get again the pop up?
Thank you and Regards!
https://redd.it/18t8mgx
@r_vim
How to keep variable in `:execute` as what it is
def Default(options: dict<any>)
for [opt, val] in items(options)
if !exists(opt)
execute opt .. $" = '{val}'"
endif
endfor
enddef
Default({
"g:plug_config_autoload": 1,
"g:plug_config_dir": expand("~/.vim/config"),
"g:plug_config_edit_command": "edit",
})
Hello, everyone.
I want to set `g:` global variable inside a dictionary. The problem is if I set as above, the value of `g:plug_config_autoload` will become `"1"` and not `1`. So if I test with `if g:plug_config_autoload` I will get an error.
How can I set variable correctly without care about their type?
Thank you.
https://redd.it/18uayrw
@r_vim
Can I use vim on the command-line to substitute some text out?
I use xclip, and I have this alias in my .bashrc file:
alias clippy='xclip -sel clip'
cmd | clippy
to post here on Reddit. However, when the output contains my username -- which is my real name -- I have to take an intermediate step and redirect the output to a file:cmd &> /tmp/file
:%s/realname/username/g
to sub in the text "username" in place of my real name in that file. And then copy that file afterwards clippy /tmp/file
.When I do brew install vim --with-python3
, I get an error saying that --with-python3
I am trying to get a plugin (vim sence) that require Python support, and me not knowing any better asked ChatGPT, who told me to run that command. However, it gives me an error, `Error: invalid option: --with-python3`, which I have looked online for and not received any help. Can anyone help with this?
https://redd.it/18uvyf2
@r_vim
Background Image
Hi mates, I would like run Neovim in Windows Terminal to be able to add background image, how to do it?
https://redd.it/18v1y3q
@r_vim
If I have an LSP installed, do I need to separately install linters and formatters?
This question pertains, practically, to Neovim, but I get the feeling the ideas behind it are extenable to the general world of text editing.
I'm following a tutorial on getting a Neovim environment started up (ignoring and adding things as fits my personal use case), but I'm a bit confused as to the difference between Linters, Formatters, and LSPs. In the third episode of the tutorial, I set up the nvim-lspconfig, mason, and mason-lspconfig plugins. In the fourth, we also configured none-ls to add specific linters and formatters. However, without a formatter for Python, I was able to format my Python code, presumably with the Python LSP I installed in my lsp-config setup. This begs the question: does the none-ls setup even really matter? What is it adding to my configuration that the LSPs, on their own, can't accomplish?
For those curious, this is my exact neovim configuration: https://github.com/MMachado05/neovim-configuration
Thank you very much in advance for the responses, and any potential insights on the functionalities of modern editors and IDEs!
Edit: The first part of the tutorial I'm following: https://www.youtube.com/watch?v=zHTeCSVAFNY
https://redd.it/18ujej3
@r_vim
When people talk about installing vim, do they mean gvim?
That seems to be the only option for windows download. I am confused.
https://redd.it/18va8s2
@r_vim
Windows, Gvim -- Vimrun.exe hanging when I run an external program from within Gvim
I am running Gvim, version 9, on Windows. To be more specific, Gvim version 9.0.2189, and Windows 11 Education, Version 23H2, Build 22631.2861. When I’m dealing with a text file, I sometimes need to reformat lines, and I like to use the “par” command for that. The par that I use is distributed with Cygwin, version 1.53, “par - filter for reformatting paragraphs”.
I use the par program by the command:
1,21!par -w78
Which means take lines 1 through 21, pass them to the external par program, and then paste the results back in place.
Recently, a few weeks back, this started giving me problems. When I run the par program from within Gvim, the process does not return. Instead I get an icon down on the taskbar. If I mouse hover on this icon, it says:
C:\\VIM\\VIM90\\vimrun.exe
“C:\\VIM\\VIM90” is the location where I have Gvim installed. If I click on the icon for vimrun, then it disappears, the Gvim process gets control back, and the lines I passed are properly formatted. In other words, everything works like it should except that I have to click on the icon for vimrun.exe in order to complete the process. I have tried a number of troubleshooting steps. I tried using “fmt” (also from Cygwin), same result. I downloaded the source code for the par program, compiled it with Tiny C, same result. I uninstalled Gvim, and installed the base 9.0 version from June of 2022, no help.
About all that’s left is to roll back Windows. Looking at my update history, on 12.13.2023 I installed KB5033375, and on 12.06.2023 I installed KB5032288. I am a little reluctant to start rolling back Windows update, sometimes that can cause more problems. Has anyone else encountered this issue?
​
ON Edit: Forget rolling back windows, the problem is with TCC.exe from Jpsoftware. If comspec is set to "cmd.exe" instead of "tcc.exe", the problem disappears. If I roll back TCC to the last version, the problem disappears.
https://redd.it/18vfj59
@r_vim
Checkov + Vim for Static Code Analysis
Has anyone incorporated Checkov and vim for static analysis?
https://redd.it/18vnzrw
@r_vim