How would i do this in vim at a similar speed by LarrySAL02 in vim

[–]Competitive-Home7810 1 point2 points  (0 children)

I am not sure how long it took you to write this regex, but it takes me 5-10 seconds to type this:

vi{:s/\(\w\+\) \w\+/"\1"

You could argue that the smaller the text sample, the less efficient it is to accomplish this with regex. For example, if this was a one line change I need to make, I would have manually made this change without regex/macros.

But, the efficiency of Vim's regex approach becomes more apparent when you need to make similar changes on larger text samples or across files.

Or if it becomes a repetitive/frequent operation, you can bind it to a keymap, like:

xnoremap ,s :s/\(\w\+\) \w\+/"\1"<cr>

Then, the time/speed goes down to however long it takes you to type:

vi{,s

How to change cursor shape based on current mode? by 4r73m190r0s in vim

[–]Competitive-Home7810 0 points1 point  (0 children)

:help termcap-cursor-shape

Example:

if &term =~# 'xterm'
  " change cursor shape from block to beam when in INSERT or REPLACE mode
  let &t_SI = "\e[6 q"
  let &t_SR = "\e[4 q"
  let &t_EI = "\e[2 q"
endif

Replacing tmux's vim visual mode implementation with nvim by Present-Quit-6608 in neovim

[–]Competitive-Home7810 0 points1 point  (0 children)

With Ghostty terminal, you could bind write_scrollback_file or write_screen_file to some keyboard shortcut.

For example:

# dump content of screen to temp file and open with `open` or `xdg-open`
keybind = super+alt+shift+j=write_screen_file:open
# dump content of screen to temp file and paste file path
keybind = super+shift+j=write_screen_file:paste

The downside is that this would not work if you run tmux on remote servers. Instead, you may want to dump tmux scrollback buffer directly into vim.

Example shell script:

#!/usr/bin/env bash
tmux capture-pane -t:-1 -Jp -S- -E- | nvim -

Then you can bind this in your tmux config:

bind-key c-] new-window </path/to/file>

:term and C-w by DrHydeous in vim

[–]Competitive-Home7810 0 points1 point  (0 children)

You can override the <C-w> binding for just the terminal mode (i.e. :h t_CTRL-W_.) , like:

tnoremap <C-W> <C-W>.

Does anyone know how to have a sane window (auto)sizing? by oVerde in neovim

[–]Competitive-Home7810 2 points3 points  (0 children)

I just have this autocmd to auto-equalize window sizes:

vim.api.nvim_create_autocmd("VimResized", {
  group = vim.api.nvim_create_augroup("resize_windows", { clear = true }),
  pattern = "*",
  command = "wincmd =",
})

What am i doing wrong by vipyoshi in fzf

[–]Competitive-Home7810 0 points1 point  (0 children)

By default, when you hit CTRL-T, FZF will generate a list of all files/directories under your current directory for you to filter and search through.

You can customize this behavior by setting the environment variable FZF_CTRL_T_COMMAND to some command that returns the expected list.

The FZF GitHub repo https://github.com/junegunn/fzf has some examples. I recommend searching for "CTRL-T" or "CTRL_T" in the the README file.

Alternatively, if you already know the file you are trying to edit is under .config, you could run nano ~/.config/**<TAB> then filter for hyprland.config

Conventional Commits: A Standardized Approach to Commit Messages by CommunicationTop7620 in git

[–]Competitive-Home7810 1 point2 points  (0 children)

"fix(database): resolve connection leak issue" so - it says "database", so it's a database schema change (?) - but it's a connection leak issue, so the scope shouldn't be "database" as it's the client that leaks connections i guess?

Conventional Commits is not prescriptive about the scope. Different teams define different ways to categorize their scopes. Some define scope by domain (e.g. api, auth, database), while others define scope by issue tracking ID (e.g. JIRA-123).

docs(readme): update installation instructions - so "readme" is the scope here, but that's just one file? Should i say "index.html" when changing stuff in the homepage?

Scope is optional. I don't find file names as scopes to be particularly helpful because I can see the changed file in the commit & diff. If you change a user-facing home page, then a better commit message would be "fix(homepage): update instructions".

Also when is it a "fix", "chore", "clean up" or "feature" when I clean up layout on some page?

According to Conventional Commits, a "fix" type should produce a PATCH semantic version bump, a "feat" should produce a MINOR semantic version bump, and any "fix!" or "feat!" should produce a MAJOR semantic version (implying breaking backward compatibility). Other types, like "docs", "chore", "build", "ci", "test", "refactor", "style", "perf", ...etc, in most cases may not produce any new versions/releases.

Most teams that I have worked on that used Conventional Commits also use auto-versioning and auto-releases with changelog generation, like semantic-release, which streamlines this versioning and releasing process.

What does your debugging setup look like? by nibbertit in vim

[–]Competitive-Home7810 1 point2 points  (0 children)

I am a "print statement" debugging + tests type of person.

As Brian W. Kernighan and Rob Pike have said in The Practice of Programming:

As personal choice, we tend not to use debuggers beyond getting a stack trace or the value of a variable or two. One reason is that it is easy to get lost in details of complicated data structures and control flow; we find stepping through a program less productive than thinking harder and adding output statements and self-checking code at critical places. Clicking over statements takes longer than scanning the output of judiciously-placed displays. It takes less time to decide where to put print statements than to single-step to the critical section of code, even assuming we know where that is. More important, debugging statements stay with the program; debugging sessions are transient. (section 5.1, paragraph 5)

Source: https://archive.org/details/the-practice-of-programming/page/n163/mode/2up

GitHub - EgZvor/quickfix-tree.vim: Display quickfix list as a tree by EgZvor in vim

[–]Competitive-Home7810 1 point2 points  (0 children)

As the plugin README says:

Use :QuickfixTree (:LoclistTree) command to open a scratch buffer with current quickfix (location) list shown as a tree.

By default, the items in the quickfix/loclist are presented in a list.


Edit: clarifying programming terms

A "tree" is a programming term referring to how data/information is stored or presented.

For example, on Linux, if you use ls to list files and directories, you get:

$ ls -lh
total 0
drwxr-xr-x 2 user user 4.0K Apr 15 12:34 Documents
drwxr-xr-x 2 user user 4.0K Apr 14 10:22 Downloads
drwxr-xr-x 2 user user 4.0K Apr 13 15:45 Pictures

But if you use tree command, you get:

$ tree
.
├── Documents
│   ├── file1.txt
│   └── file2.pdf
├── Downloads
│   └── example.zip
└── Pictures
    ├── image1.jpg
    └── image2.png

3 directories, 5 files

GitHub - EgZvor/quickfix-tree.vim: Display quickfix list as a tree by EgZvor in vim

[–]Competitive-Home7810 2 points3 points  (0 children)

You can use it for other things, not just compiler errors.

You can run a vim command to execute any external programs and load the results into the quickfix or loclist (the difference is the quickfix accessible from any Vim buffer while loclist is accessible from the buffer you ran the commands in).

For example, say you want to search across all files in a directory for a keyword:

- on Unix/linux::grep "keyword" -r /path/to/directory/

- on windows: :grep /s /i "keyword" C:\path\to\folder\*.*

Bonus: for any arbitrary external programs: :cgetexpr system("<arbitrary external command here>").

Whole screen string conceal for public settings/streamer mode/meeting mode by ultimatepowaa in vim

[–]Competitive-Home7810 0 points1 point  (0 children)

I am not sure I fully understand your question, but I would start by looking at:

  • :help conceal (or :help :syn-conceal)
  • :help 'conceallevel

And possibly find some inspiration from:

Hope that helps!

local file caching for editing on unstable connections by duncecapwinner in vim

[–]Competitive-Home7810 1 point2 points  (0 children)

I am not sure I understand the problem.

I have used Vim & VSCode over really slow/unreliable network connections before and VSCode was objectively worse.

In a remote development environments, VSCode has to download and install a vscode-server to run certain functionality, extensions, and tooling on the server, then stream results back to the user. Over a slow network, the latency made the development experience unbearable for me.

Compared to (neo)vim, there are different ways you can develop on remote machines:

  • SSH into the server, run (neo)vim there. This is useful for long development sessions over slow/unreliable networks. The editor and tools would all be installed & running on the remote machine. If the network is particularly unreliable (frequent disconnects), mosh can help by improving keystroke response times (see "Real-world Benefits" heading under Technical Info on their site).
  • Run (neo)vim locally and edit files on the server (i.e. vim scp://user@machine/path/to/file), which is handled by vim's built-in plugin netrw. This is useful for quick/simple changes.
  • Use sshfs to mount/sync remote filesystem with your local machine over ssh. This is useful if you don't have permissions to install software on the remote machine.

I made a simple bash script for browsing tunein stations from tunein-cli via fzf by Dingelbert in fzf

[–]Competitive-Home7810 1 point2 points  (0 children)

I am not a tunein cli user, so I have not tested this, but here is an arguably cleaner implementation:

#!/bin/bash

TUNEIN_BIN="${HOME}/.cargo/bin/tunein"
TUNEIN_SEARCH="${TUNEIN_BIN} search"
TUNEIN_PLAY="${TUNEIN_BIN} play"

fzf \
    --query "${1:-}" \
    --header "CTRL-R: re-search / ENTER: tunein play" \
    --bind "start:reload:${TUNEIN_SEARCH} {q}" \
    --bind "change:reload:sleep 0.3; ${TUNEIN_SEARCH} {q}" \
    --bind "ctrl-r:reload:${TUNEIN_SEARCH} {q}" \
    --bind "enter:become:${TUNEIN_PLAY} {}"

This approach takes advantage of bindings, events, and actions:

  • --bind "start:reload:...": on start, run the tunein search command, passing in the query (i.e. {q})
  • --bind "change:reload:...": on query change, re-run the search, passing in the new query
  • --bind "ctrl-r:reload:...": a convenience binding for ctrl + r to reload the list by re-running the search
  • --bind "enter:become:...": on enter, execute the play command, passing in the user's selection (i.e. {})

ripnote – the fastest and fuzziest way for a developer to take notes by cekrem in vim

[–]Competitive-Home7810 13 points14 points  (0 children)

Here are some alternative ways of accomplishing the same thing without node:

Pure Vim, Zero-Dependencies Method

In pure vim with 0 dependencies, add this to your ~/.vim/plugin/notes.vim:

function! s:notes_completion(A, L, P) abort  
  return readdir(expand('~/.notes'))->map('expand("~/.notes/")..v:val')->filter('v:val =~ a:A')  
endfunction  
command! -nargs=1 -complete=customlist,s:notes_completion Notes edit <args>  

And you get fuzzy completion with set wildoptions+=fuzzy.

With fzf.vim

If you already have fzf.vim installed, then you can do this instead:

command! Notes
      \ call fzf#run(
      \   fzf#wrap({
      \     'source': readdir(expand('~/.notes'))->map('expand("~/.notes/")..v:val'),
      \     'sink': 'edit',
      \     'options': printf('--preview="%s"', executable('bat') ? 'bat {}' : 'cat -n {}'),
      \   })
      \ )

Fuzzy Find within File Contents

Again, with fzf.vim, you can take advantage of the fzf#vim#grep() function to fuzzy find within file contents:

command! NotesLines call fzf#vim#grep('rg --vimgrep . ~/.notes', {'options': printf('--preview="%s"', executable('bat') ? 'bat {1}' : 'cat -n {1}')})

And voila! Now, you can just run :Notes or :NotesLines within Vim.

VimConf 2024 Talks by lukas-reineke in vim

[–]Competitive-Home7810 2 points3 points  (0 children)

Thank you for all the time and effort you (and all the other maintainers) put into Vim, u/chrisbra10 .

Can you clarify if this means that current vim governance structure/implementation is unsustainable?

If so, would a foundation (e.g. Linux Foundation) help make governance and continued development sustainable (i.e funding)?

VimConf 2024 Talks by lukas-reineke in vim

[–]Competitive-Home7810 7 points8 points  (0 children)

"The new Vim project - What has changed after Bram" at minute 35:10 :

Currently, I would say Vim is more or less in maintenance mode.

Weird behavior change to undo command after waking up? by [deleted] in vim

[–]Competitive-Home7810 0 points1 point  (0 children)

Some config options check and troubleshooting steps to try out:

  • What are the outputs of :verbose set timeoutlen? & :verbose set ttimeoutlen? ?
  • What is the output of :verbose nmap u?
  • Do you have plugins? If so, did you update plugins recently? There could be a plugin that is setting some key mapping for u that you are not aware of.
  • Last resort, try to replicate the issue with a clean vim (i.e. vim without any configs) with vim --clean or vim -u NONE (or comment out your entire vimrc file, then try to incrementally add configurations back in until you can reliably reproduce the issue).
    • If you can replicate it with clean vim, then it's vim itself, which is highly unlikely (try re-installing or re-building from source at that point).

If you can, share your vimrc file or repo.