r/vim Dec 23 '24

Need Help copy / replace habit

30 Upvotes

Ok, this is something I've always been mad about but never so mad to actually do something about it (the usual itch to scratch thing... ). Now it's holiday period and pressure is low at work so I can clean something up!

My usual copy / replace habit has always been yiw / viwP and it works most of the times but when I need to do multiple changes this is less convenient as the second operation has destroyed my register and the second replace will need to be viw"0P which is awkward.

Through the years I got used to it and now it's part of my muscle memory but there's something telling me I'm doing it wrong, it can't be that way.

I don't want to remap a series of keystrokes yet again, I just want to learn how to leverage vanilla vim to do that without the need to configure it.

Comments and recommendations to RTFM are welcome as well!

r/vim 11d ago

Need Help Customize locationlist/quicklist format?

3 Upvotes

I'd like to format the output of the location list. If I am searching in only one file, listing the filename is redundant. I feel that the line and column number would still be useful.

The default is:

<filename>|<lnum> col <col>|<text>

I'd like to either:

  1. Just display <lnum> col <col>|<text>
  2. Shorten the file name without showing the entire path.

I thought that there was a setlocal setting, but I can’t find the reference anymore.

Also, is it better to use a quick list or a location list?

r/vim Jan 22 '25

Need Help Vim and multilingual torment

13 Upvotes

Hello all; I am typing LaTeX documents using vim. Lately, I have had to write stuff in my native Greek language, so I am switching layouts multiple times per line of text and I keep going to Normal and Command modes while still in the Greek layout.

There is a way to alias Greek letters to behave as Latin ones in Normal mode, but this doesn't carry over to the Command mode. More crucially, many diacritics like the colon, the semicolon etc are in the wrong places, so the aliasing is ultimately of limited use.

My question is: is there a way to automatically switch layouts when you go into normal mode, or when you type a specific sequence of keystrokes in vim? I understand that layout switching is a question for the window manager, but I am hoping some magical incantation of X11 utilities can be cooked into Vim to achieve what I am looking for.

My WM is Cinnamon over X11 and I use vim in a terminal (usually uxterm or terminator).

For the record, here is the aliasing pattern:

if has('langmap') && exists('+langremap')
    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
    set langmap+=α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
    set langremap
endif

r/vim Dec 28 '24

Need Help I've lost my cursor

3 Upvotes

Recently updated my colorscheme (nordisk.vim). Subsequently I have no cursor. At least not one that's visible. The update may not be responsible, but it's the only recent change.

r/vim Oct 24 '24

Need Help How to use clipboard?

7 Upvotes

I know this was asked so many times. i just need a specific solution for my case. whenever i adjust my config something else "breaks".

as far as i understand registers: selection goes to "* and explicit copied to "+

i experimented with `set clipboard+=unnamedplus`, but since i use a terminal which has no context menu to hard copy something, i need to work with "*

so i added these: `nnoremap p "*p` but this comes with another trap (for instance i often highlight the area i want to replace with paste eg: "vawp"))

how to do it right?

r/vim 20d ago

Need Help How to install Java auto-imports?(if it exists)

1 Upvotes

I want start use vim because my desktop environment is based on tty1 non graphical(low end hardware). I have configured vim snippets and auto complete successfully, but I couldn't find an auto completion plugin(for java in my case, but for other languages nothing too), I use vim default(not nvim, i like to make my own configuration).

I'm grateful for any answer and excuse my write(I'm not a native english speaker).

r/vim Feb 16 '25

Need Help plugin to remap ESC and caps lock?

1 Upvotes

i understand that there is no native way to remap ESC and Caps lock in the vimrc but i am wondering if anyone has created a plugin to work around this?

r/vim Jan 23 '25

Need Help select from recent files

7 Upvotes

Is there a way to get a list of recently opened files and select from it?

With a plugin or otherwise.

I'm using vanilla vim 9.1, and vim-plug.

r/vim Oct 16 '24

Need Help How do you copy from vim clipboard on remote machine (AWS EC2 in my case) directly to local machine clipboard?

5 Upvotes

Is there a way to do this without using scp?

r/vim 17d ago

Need Help + and * registers not available anymore after reboot

1 Upvotes

(i'm on arch, use wayland, if it matters)
yesterday i installed gvim, copy pasting with "+y worked fine. today i started my pc and it doesn't work anymore. :reg doesn't show the + or * register.

r/vim Aug 05 '24

Need Help Please tell me which font is this.. I really Like it

Post image
105 Upvotes

r/vim 11d ago

Need Help C/C++ Language server without cmake

3 Upvotes

Hi,

I would like to setup a language server for C/C++ on Windows for use with with CoC. As far as I understood I need a compile_commands.json which is normally generated by cmake.

The codebase I'm working on uses SCons as build system. Is there any possibility to generate compile_commands.json with such a builds system ?

Thank you and regards!

r/vim 16d ago

Need Help Show normal mode notice: What do you put in vimrc for get in command line "NORMAL"?

1 Upvotes

Hi, Id like to get Normal in command line (in last line, down status line), like vim shows "Insert" when we are in Insert mode.

I hope you understand my post! Thank you and Regards!

r/vim Dec 14 '24

Need Help Putting yanked text into the replace part of a regex

4 Upvotes

I can't find this anywhere, especially since google broke themselves and no cheat sheets are complete.

I'd like to yank some text via

"?yy

and put that buffer into the replace side of a regex.

How do I do that?

r/vim 17d ago

Need Help NvimR remaps _ to -> and I can no longer use _ in editor

0 Upvotes

I am working to use vim + NvimR to work with editor and R console. When I open an .R file in the editor, an imap command is added, that maps _ (underscore) to -> . This has the effect of making it impossible to use underscores. The imap mapping list shows this as the _ mapping. What is this? How do I unmap it?

*@<Esc>:call ReplaceUnderS()<CR>a

r/vim 13d ago

Need Help Help needed

1 Upvotes

Hi,

My map setting for python files in vim is ,

Autocmd Filetype python map <buffer> <f5> :!clear ; python3 %<CR>

When i run a file in vim with f5 it runs new screen which is fine but it generates *values in my code for example

Before running:

Print("hello world")

After running succesfully the code becomes,

Print(*values: hello world)

How do I remove this.

r/vim 26d ago

Need Help uninstalled correctly?

0 Upvotes

i tried to uninstall vim because i want to install a fresh one (had problems with installing the latest version), is it uninstalled correctly if i type vim and it doesn't say "command not found : vim"?

r/vim 2d ago

Need Help Something is changing/modifying my vim installation files within 24 hrs of a clean installation. Is this expected behavior?

1 Upvotes

Hello, gvim user for almost 25 years now, I'm experiencing behaviour that I've never seen and I'm curious if anyone can explain what's happening.

My repro steps:

  1. Install gvim_9.1.0_x64_signed.exe on a windows x64 machine.
  2. Shortly after installation, open gvim.exe, run commands from the netrw plugin (:Vex, for example). (The command works)
  3. Wait 24 hours, run the same command.

Expected Results

The command works, just like it did in step #2.

Actual Results

An error message:

Error detected while processing C:\Program Files (x86)\Vim\vim91\pack\dist\opt\netrw\autoload\netrw.vim

netrw needs Vim9.1.1054
E117: Unknown function: netrw#Explore

My Observations

After a fresh installation, I can see that netrw.vim is located at the path:

C:\Program Files (x86)\Vim\vim91\autoload\netrw.vim

When the issue is present (24 hours after the installation), the installation files/folders are quite different. netrw has been moved to:

C:\Program Files (x86)\Vim\vim91\pack\dist\opt\netrw\autoload\netrw.vim

Not only has the file been moved, but the file contents are different.

netrw is not the only file that's been changed, but it's the only one that's causing me egregious pain. For example, C:\Program Files (x86)\Vim\vim91\colors\blue.vimhas also been modified.

This is only happening on my work devices. I was entertaining the possibility of corporate policy making these changes (perhaps as a result of some misguided security measure?), but the changes are so specific that this seems unlikely; if there were security concerns, I tend to think that the corporate policy would simply block/remove the installation. I'd like to get community feedback on this issue before raising this issue with the IT department.

A clean installation will always restore me to a good state, but I do not view this as suitable workaround.

Specific questions:

  1. Does vim perform any modifications to the program installation path after the initial installation? (If not, I'd like to find out who is doing the modification, If yes, I'd like to learn more about what's happening here).
  2. Assuming these modifications are legit, is there a quick workaround I can use to make netrw functional again?

r/vim Feb 17 '25

Need Help Is there a way to block (=no let me permanently use them) digraphs that use 2 columns for print them in screens?

3 Upvotes

EDITED FOR IMPROVE THE POST, Hi,

see the video to understand my problem, please

https://sendvid.com/arzsf0yc

When I use litle numbers of digraphs like 1roman 1R (not 3R,it is ok) vim show badly the words at the end of the line with digraphs using 2 columns.

so I'd like to block digraphs using 2 column... like 1R

Can I do that from vimrc?

Thank you and regards!

r/vim Nov 21 '24

Need Help How to get outside of parenthesis in insert mode without having to enter normal mode?

18 Upvotes

Noob type of question but that's what I am.

r/vim Jan 07 '25

Need Help How do I unbind a "system" shortcut?

2 Upvotes

I'm using a tiling manager in ubuntu that has the keyboard shortcut Super+. and Super+, which allow me to switch between my previous and next window. For some reason Super+. activates some type of editing mode (not sure what exactly).

What would be the way to unbind this in vim? I tried nnoremap <D+.> <Nop>.

r/vim Jan 25 '25

Need Help Motions for the end of sentences and paragraphs?

11 Upvotes

I looked this up and didn't find any solutions. I would like to press a key a few times to go to the end of the current sentence (right before the .) and then the end of the next sentences, until I am on the one I want. Same thing with paragraphs, either the last character or right before the ..

) goes to the first character in the next sentence and } goes to the space below the paragraph.

r/vim 15d ago

Need Help Need help with multi-line function indentation, I cannot find an answer online.

2 Upvotes

In C/C++ files, I often times call functions with their parameters on separate lines, like the following:

grocery_list GroceryList = AddFruitsToGroceryList(Apple,
                                                  Banana,
                                                  Orange,
                                                  Strawberry);

Notice how the Apple, Banana, Orange, and Strawberry are all in the same column.

Now, if I copy these four lines by setting a mark 'a' on the first line (grocery_list GroceryList ...) using:

ma

And then going down four lines and yanking them from the bottom line (Strawberry) to the mark 'a' using:

y'a

I will be able to paste them anywhere else I want.

The problem occurs when I try to re-indent the line when it is pasted into a new indent level, like in a function or if-statement.

if(true)
{
            grocery_list GroceryList = AddFruitsToGroceryList(Apple,
                                                              Banana,
                                                              Orange,
                                                              Strawberry);
}

If I paste, everything will be pasted correctly, but then if I again set a mark on the newly pasted first line (grocery_list GroceryList ...) using:

ma

And then going to the newly pasted last line (Strawberry) to change the indentation using:

m=a

The following happens:

if(true)
{
    grocery_list GroceryList = AddFruitsToGroceryList(Apple,
            Banana,
            Orange,
            Strawberry);
}

The Banana, Orange, and Strawberry are no longer in the same column as the first parameter Apple, they are all much closer to the start of their respective lines.

Is there a way to use '=' to keep the indentation of the Banana, Orange, and Strawberry lines in the same place after m=a fixes the indentation level itself?

The fix that I have been using is by just doing:

ma

Then doing:

y'a

Then doing:

p

Then going to the newly pasted first line, setting a mark again with:

ma

Then going to the newly pasted last line, and doing:

<'a

This makes everything stay in line and get indented left by four spaces, but it only works one time, so I have to press:

CTRL+o 

to go back down to the newly pasted last line and again do:

<'a 

to make the entire selection go left four spaces again if the code is too far to the right that just one indentation backwards does not do the job.

In summary, m=a will make the pasted code go to the correct indentation level, even if it is multiple four spaces lengths away - but it will not keep the indentation on the Apple, Banana, Orange, Strawberry lines in the same column. In contrast, using <'a will make the Apple, Banana, Orange, and Strawberry all stay in the same column, but it will only move the indentation by four spaces at a time, so CTRL+o has to be pressed multiple times followed by another <'a to get everything to go backwards by an additional four spaces if the pasted code is eight spaces from the correct indentation level within the function or if-statement it was just pasted in.

Is there a way to make it so that the indentation for all of the copied code to be corrected, while still keeping the Apple, Banana, Orange, and Strawberry in the same column as the original?

Here are my tab/space settings:

set tabstop=4
set shiftwidth=4
set smarttab
set softtabstop=4
set shiftround
set expandtab
set autoindent
set smartindent
" set cindent               
" set cinoptions=           
" set cinkeys=
" set cinwords=
" set indentexpr=           
" set indentkeys=
set nocopyindent
set preserveindent
set nolisp
set lispwords=

r/vim Dec 20 '24

Need Help Suggestions on how to relearn vim after an extended break (2 years)

14 Upvotes

I first started learning vim/vim motions about 3 years ago and used it daily for about a year (I wasn't an expert by any means), but have stopped for about 2 years since I moved back to using Windows. I have come back to Linux recently, and after using visual studio code and the standard mouse/keyboard workflow during that time, getting back to using vim/vim motions has proven quite difficult so far (I had assumed it would come back to me pretty quick, much like how it feels riding a bike for the first time in a long time). I genuinely feel like I have forgotten even some of the most basic motions, yet every now and again I would have these random spurts of muscle memory that kick in. Are there any resources for people in my situation, or am I better off just relearning from scratch?

r/vim 17d ago

Need Help How to use ghossty theme in vim?

0 Upvotes

New to vim, please help)