/r/vim

Photograph via snooOG

The place for questions and conversation on the Vim editor


Please read the rules before posting


Help:

Community:

Resources:

Tutorials and Guides:


Don't be afraid to ask questions, this sub is here for the vim community. And please those of you who deign to grace us with your vim wisdom - be kind. We are all human and vim is that cool.

/r/vim

178,784 Subscribers

1

Vim colors with PuTTY & Synology SSH connection?

I connect to my NAS through SSH using PuTTY. Terminal-type string is set to xterm-256color and when I'm connected.

user@NAS:~$ echo $TERM
xterm-256color

When opening a .sh file with vim, I do get some color. I can also edit the PS1 variable.

However, I can't change the color by adding vim colorscheme file. I tried, I can enumerate them with the :colorscheme command, but they won't load.

Vim 8.2

Note that this one halfway works :

https://github.com/fugalh/desert.vim/blob/master/colors/desert.vim

3 Comments
2024/12/02
18:32 UTC

1

How to replace fixed lines around arbitrary code block?

I have the following text:

line above
<many different lines>
line below
...
line above
<many different lines>
line below
...
<and so on>

How would you change it to:

another above line
<many different lines>
another below line
...
another above line
<many different lines>
another below line
...
<and so on>

In the most effective vim way. TIA

4 Comments
2024/12/02
15:34 UTC

6

How to enable the editorconfig plugin which is bundled with vim?

I have manually compiled and installed VIM. Apparently, VIM already has this plugin bundled in /usr/share/vim/vim91/pack/dist/opt/editorconfig.

So how am I supposed to enable this plugin?

4 Comments
2024/12/02
14:52 UTC

0

Thoughts on replacing w W b B j k with motion plugin(s)?

I replaced w W b B j k motions with hop commands, using char1 commands for w and b where I type one character and then the hint on the one I want to move to. I use :HopVertical for j and k, its similar to char 1 but for vertical lines. If I need to move no more than a few lines or chars I'll just quickly hold h j k l for only ~1 second, since I have a high char repeat rate and low char delay on my mac. So far I've found this more efficient then remembering to use either lower or uppercase W B Es, and I don't need to calculate relative word or line number counts, its less thinking to get to move where I want. I also disabled relative and absolute line numbers altogether, if I need the line number I can look at my Lualine.

-- Replace w and b with hop character searching
for _, key in ipairs({"b", "B"}) do
vim.keymap.set({"n", "v", "o"}, key, function() require'hop'.hint_char1({ direction = require'hop.hint'.HintDirection.BEFORE_CURSOR }) end, opts) end
for _, key in ipairs({"w", "W"}) do
vim.keymap.set({"n", "v", "o"}, key, function() require'hop'.hint_char1({ direction = require'hop.hint'.HintDirection.AFTER_CURSOR }) end, opts) end

-- Replace j and k with Hop to use letter hints instead of relative line numbers
for _, key in ipairs({"j", "k"}) do
	vim.keymap.set({"n", "v"}, key, "<cmd>HopVertical<cr>", opts)
	vim.keymap.set("o", key, "V<cmd>HopLine<cr>", opts)
end
16 Comments
2024/12/02
06:07 UTC

1

Vieb vim web browser

hi all.

Vieb released a new version last week. https://github.com/Jelmerro/Vieb/releases/tag/12.1.0 anyone in here have experience with it? looks really nice but im unsure if i should jump in.

0 Comments
2024/12/01
15:01 UTC

12

VIm for web dev

Want to switch to but mostly gunna use it for web dev(React, TS, Nextjs) some python.

What are your must need plugins for web dev?

45 Comments
2024/12/01
21:56 UTC

2

colorscheme not displaying properly

https://preview.redd.it/sw4memj8284e1.png?width=1918&format=png&auto=webp&s=61bf5ccc5fa874552c702611b998374da8bba8e2

here the green , color on the bottom is the color of my alacritty terminal i use solarized theme in alacritty but this issue presists even when i use different terminal

for example:

https://preview.redd.it/a9ww1zai284e1.png?width=1916&format=png&auto=webp&s=2d71387a0da5111f3d4e7bc07a80bf016f5f44f9

this is linux mint's default terminal

here are my .vimrc

call plug#begin()

`Plug 'joshdick/onedark.vim'`

`Plug 'itchyny/lightline.vim'`

`Plug 'preservim/nerdtree'`

call plug#end()

"line under current lineshit

"set cursorline

"set culopt=line

set ignorecase

set ai

set hlsearch

nnoremap <silent> <leader><space> :nohlsearch<CR>

highlight MatchParen ctermfg=black ctermbg=4

colorscheme onedark

"colorscheme solarized

augroup PeachPuffCustomHighlights

autocmd!

autocmd VimEnter * if exists('g:colors_name') && g:colors_name ==# 'peachpuff' | call ApplyPeachPuffHighlights() | endif

autocmd ColorScheme peachpuff call ApplyPeachPuffHighlights()

augroup END

function! ApplyPeachPuffHighlights()

 `highlight MatchParen ctermfg=black ctermbg=4`

highlight Pmenu ctermbg=gray

highlight PmenuSel ctermbg=black ctermfg=White

highlight Search ctermfg=black ctermbg=white

highlight Visual ctermfg=12 ctermbg=White

endfunction

inoremap jk <Esc>

inoremap kj <Esc>

inoremap jj <Esc>

inoremap kk <Esc>

set guioptions -=m

set guioptions -=T

filetype indent on

vnoremap <C-c> "+y

map <C-p> "+p

highlight Comment ctermfg=green

set number

set tabstop=3

set shiftwidth=3

set noswapfile

set noshowmatch

set mouse=a

set nobackup

"let &t_SI = "\e[6 q"

"let &t_EI = "\e[2 q"

"let &t_SR = "\e[4 q"

"nerdtree stuff

let NERDTreeWinSize = 30 " Set the width to 30 columns

nnoremap <leader>n :NERDTreeFocus<CR>

nnoremap <C-n> :NERDTree<CR>

nnoremap <C-t> :NERDTreeToggle<CR>

nnoremap <C-f> :NERDTreeFind<CR>

2 Comments
2024/12/01
11:27 UTC

1

Swap o and a

Hi, i find it way more intuitive to have o to place me in insert mode to the right. With such a remap it is i for insert at left and o to insert at right as they are on a qwerty keyboard next to each other. But i know that this is a very concrete keybinding in vim. And people always tell to not touch the defaults. Is this such a big problem. They say, if you have to edit some remote server you should be able to be smooth with the defaults, or if you are working at a company and you have to share config with other people, you have to use the defaults. Is this true. How much time do you typycally spend on a vanilla vim on some remote server. Do you just enter to do some quick change, or is it more involved. Should i configure vim how i like, or should i force myself to use the defaults, because if not, i would be unemployable for such jobs, or at least having a hard time.

21 Comments
2024/11/30
23:34 UTC

1

Automatically run command

Already opened editor buffer and terminal buffer, while switch to editor buffer to terminal. Automatically run command ( eg:- node abc.js )

Is that possible with of autocmd or other ???

8 Comments
2024/11/30
19:40 UTC

14

System-wide Vim principles (Linux)

Is it possible to implement Vim-like editing principles system-wide, independent of an application where a text field is?

I'm extremely interested in that. There are plugins for browsers and IDEs, but what about making Vim navigation and editing conventions work in any text field? There's no talk about transferring all features, but the basics at least.

Is there somebody who was trying to do that? If you did, doesn't matter what desktop environment or window manager you use, share what you got!

22 Comments
2024/11/30
14:08 UTC

1

Need help to identify plugin

Can anyone identify the plugin in the header of vim, which shows the pressed keys? https://youtu.be/tF6NDPoWovM At least I think it is a vim plugin.

EDIT:
Found this: https://github.com/rwxrob/dot/blob/main/vim/vimrc, line 193: seems to be a nvim-plugin https://github.com/NStefan002/screenkey.nvim Is there something similar for Vim?

2 Comments
2024/11/29
13:30 UTC

78

Why is there a red line down my Vim session?

47 Comments
2024/11/29
03:32 UTC

6

use commitizen from vim

Hello, after three years of internal politics I've finally managed to get the go ahead to get the team to use conventional commits in our repos. So now I'd like to get a step further and use commitizen in my preferred editor, to facilitate commits writing.

Up until now my go to place to commit was directly from my editor, using the essential vim-fugitive plugin. You hit cc after having staged your changes and you are in your commit message.

That's a hard habit to break, so I thought "what if hitting cc would open a :terminal instead and run cz commit instead ?" That would be rather elegant, as I wouldn't need to leave my editor and still benefit from the commandline tool. I think I could also achieve the same result leveraging Vimux.

Now comes the real problem, how to achieve any of the above? I might be well versed at using plugins and configuring them, but I've never done anything "custom" and I'm stuck with my "blank page syndrome"! Any guidance ?

5 Comments
2024/11/28
09:04 UTC

9

Why does a ":syn match" disable another ":syn match"?

I have this text,

Type@500ms "Something"

I want to highlight Type with something (tapeKeyword) and @500ms with something else(tapeSpeed).

And I have this in my syntax file

syn match   tapeKeyword          /\zsType\ze@\d\+ms/
syn match   tapeSpeed            /\Type\zs@\d\+ms\ze/

Why does the first line disable the second line? If I commented the first line and the second gets highlighted correctly?

Apologies for the ugly pattern as I am quite new with regex & vimscript.

3 Comments
2024/11/28
06:26 UTC

2

Vim9script linter

Hi, I'm considering to port one of my Neovim plugin to Vim9, so I'm looking for a Vim9script linter or language server. Do you have any recommendations?

9 Comments
2024/11/27
12:08 UTC

0

A 'K' mapping for your ftplugin/vim.vim file.

(I meant in your .vim/after/ftplugin/vim.vim file.)

Edited! I now expand <cWORD>, which makes it better than setlocal keywordprg=help. It will work on both :substitute and substitute(.

The mapping of 'K' in buffers containing vim script looks up the word under cursor in vim help, like in bash or c buffers. (I recommend installing Man.vim for C programming at least.)

nnoremap <nowait><silent><buffer> K :help <C-R>=expand("<cWORD>")<CR><CR>
15 Comments
2024/11/26
20:10 UTC

8 Comments
2024/11/26
01:14 UTC

11

Vim Challenge: for each line containing pattern reindent it with the level of a previous line

Pattern in.

Before

    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.
            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.

After

    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.
            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.
23 Comments
2024/11/25
21:39 UTC

22

vimwiki to deployed website

Hi, Here is the method by which i instantly update and deploy my vimwiki as a website to my server using the mdwiki and gitlab pipelines

I hope somebody will find it useful

Here is the video https://youtu.be/d2rSk3vk9e4?si=99dZ3Gui6p0T3OSm

0 Comments
2024/11/24
21:12 UTC

3

are there ways to use the Windows/Cmd button as keybinds in .vimrc?

I'm pretty new to vim, but i got the hang of .vimrc pretty quickly. i already have a few plugins installed (including Vundle and NerdTree), and i just want to be able to have vim enter the keybinds for maximizing a window in windows. is there a plugin that allows vim to use these keybinds? if not, is there a way i can connect the startup of vim with a keybind in windows? just curious cuz i can't be arsed to always maximize my window

7 Comments
2024/11/24
00:40 UTC

40

How do you make vim second nature?

I've been trying to learn vim for almost 2 weeks now by using vim even if it's slower at first. So far I've just been using /, ?, y, p, u, o, O, gg, G. I figured I would start with the basics and master them before doing anything else. This has been okay except for a few things.

When I'm trying to jump to a word or something, there's so many instances of each word so I can't just go bam bam bam I have to search look search look to see where I am (which is much slower than just scrolling). The other thing is selecting/yank/put, I can't move code around fast at all because well I move it and then I have to use my mouse to reformat it all to make it look clean again.

Not sure if I explained this but it feels not like I don't have enough experience but just that I'm missing something?

59 Comments
2024/11/24
00:15 UTC

6

Fugitive dv 3-way merge in new tab?

Is there a way to open the 3 buffers (opened with `dv`) at the bottom in a new tab instead?

https://preview.redd.it/7g06ulaplm2e1.png?width=3840&format=png&auto=webp&s=0a912c54c26866382ec9a00d893f84a2f54a6603

6 Comments
2024/11/23
10:12 UTC

2

how to add newline in this - :for i in range(0, 255) | put ='case 0x'.printf('%02X', i) | endfor

I tried \\n and /\n, but i can't get it to give me a newline

6 Comments
2024/11/23
06:32 UTC

0

How do you write a search starting * or | plus 4+ words?

Edited: Hi. how is a search starting with * or | (|=digr vv) plus 4 words or more words ?

I need to short titles so they start with | or * from boxes round them.

thank you and regards!

9 Comments
2024/11/22
21:18 UTC

6 Comments
2024/11/22
19:14 UTC

0

Apple cannot verify [filename] is free of malware

I have a few old .vimrcs I thought I saved as plain text files without the .. I'm guessing from the images associated with the files in the directory that they are instead code files.

In any case, when I attempt to open the files with textedit I get a popup with this warning: "Apple could not verify 'vimrc-pandoc-markdown' is free of malware that may harm your Mac."

2 Comments
2024/11/22
19:03 UTC

2

fix color

I tried to change the color for cpp files, but if the slash is at the beginning of the line it doesn't change correctly

autocmd FileType cpp syntax match cppNamespace /\w\+\ze\s*::/

autocmd FileType cpp highlight cppNamespace guifg=#FF5733

https://preview.redd.it/cl8a2gpicd2e1.jpg?width=602&format=pjpg&auto=webp&s=a81dfcac18dbf07497f64e88a98bb2c3685e9617

1 Comment
2024/11/22
03:03 UTC

52

Vimium is amazing and depressing at the same time

I feel hooked on vimium when I am hitting the right keys and moving around in the right way. It's like playing a game and hitting combos. I'm not great but still. Especially because the browser felt like such a GUI refuge that those of us who like the terminal and that type of text-flow just had to deal with throwing it out of the window when we needed to browse. Frankly, the browser is the most time I ever spent in GUI software. I obviously jump into other things but nothing compares to the browser. Vimium really helped make a major change.

The only issue is that it doesn't always work. I get that it's not up to Vimium a lot of the times it's just the way some devs wrote their html. But it feels like you're stopped in your tracks all of a sudden. When you're flowing well and the Skip button on youtube doesn't work or you can't enter the comment field in reddit it feels like the vim version of getting wired headphones yanked out of your ears.... awful.

But damn when it flows, it flows! Feels nice to keep that workflow. Nothing much to say, just enjoying it and spewing a bit of praise.

Literally as I finished on that high note I tried using vimium to click the Post button and it didn't work. Ahhh such is life sweet, can't vimium all

Actually it turns out I just didn't add a flair... you CAN vim 'em all!! LONG LIVE VIM ET ALL

27 Comments
2024/11/21
23:43 UTC

Back To Top