Vim9 TeXpresso Integration?
Anyone have a solution for integrating TeXpresso into Vim9?
https://redd.it/1otug2q
@r_vim
Anyone have a solution for integrating TeXpresso into Vim9?
https://redd.it/1otug2q
@r_vim
GitHub
GitHub - let-def/texpresso: TeXpresso: live rendering and error reporting for LaTeX
TeXpresso: live rendering and error reporting for LaTeX - let-def/texpresso
A Python function I use to build project files from my Ultisnips snippets
I have a few noscripts I use for setting up projects different ways. This is the function I use to build project files from my Ultisnips snippets. Nothing ground breaking, but I've gotten a lot of use out of it.
import re
from pathlib import Path
def select_snippet(
snippet_file: Path, snippet_trigger: str, subs: dict[str, str] | None = None
) -> str:
"""Select a snippet file and fill in the template with substitutions.
:param snippet_file: Path to the file containing snippets.
:param snippet_trigger: The trigger for the snippet to select.
:param subs: Optional dictionary of substitutions to apply to the snippet.
:return: The formatted snippet as a string.
"""
pattern = re.compile(rf"snippet {snippet_trigger}(.*?)endsnippet", re.DOTALL)
with snippet_file.open() as f:
match = re.search(pattern, f.read())
if not match:
msg = f"Snippet {snippet_trigger} not found in {snippet_file}"
raise ValueError(msg)
match_str = "\n".join(match.group(1).split("\n")[1:])
for k, v in (subs or {}).items():
match_str = re.sub(k, v, match_str)
return match_str
# ===========================================================
# Example usage
# ===========================================================
SNIPPETS_DIR = Path.home() / "vimfiles" / "ultisnips"
PROJECT_ROOT = Path("to", "project", "root")
def write_pre_commit_config(python_min_version: str) -> None:
"""Write a pre-commit configuration file."""
yaml_snippets = SNIPPETS_DIR / "yaml.snippets"
subs = {r"\$1": python_min_version}
with (PROJECT_ROOT / ".pre-commit-config.yaml").open("w") as f:
_ = f.write(select_snippet(yaml_snippets, "pre-commit-config", subs))
https://redd.it/1ow5vr4
@r_vim
I have a few noscripts I use for setting up projects different ways. This is the function I use to build project files from my Ultisnips snippets. Nothing ground breaking, but I've gotten a lot of use out of it.
import re
from pathlib import Path
def select_snippet(
snippet_file: Path, snippet_trigger: str, subs: dict[str, str] | None = None
) -> str:
"""Select a snippet file and fill in the template with substitutions.
:param snippet_file: Path to the file containing snippets.
:param snippet_trigger: The trigger for the snippet to select.
:param subs: Optional dictionary of substitutions to apply to the snippet.
:return: The formatted snippet as a string.
"""
pattern = re.compile(rf"snippet {snippet_trigger}(.*?)endsnippet", re.DOTALL)
with snippet_file.open() as f:
match = re.search(pattern, f.read())
if not match:
msg = f"Snippet {snippet_trigger} not found in {snippet_file}"
raise ValueError(msg)
match_str = "\n".join(match.group(1).split("\n")[1:])
for k, v in (subs or {}).items():
match_str = re.sub(k, v, match_str)
return match_str
# ===========================================================
# Example usage
# ===========================================================
SNIPPETS_DIR = Path.home() / "vimfiles" / "ultisnips"
PROJECT_ROOT = Path("to", "project", "root")
def write_pre_commit_config(python_min_version: str) -> None:
"""Write a pre-commit configuration file."""
yaml_snippets = SNIPPETS_DIR / "yaml.snippets"
subs = {r"\$1": python_min_version}
with (PROJECT_ROOT / ".pre-commit-config.yaml").open("w") as f:
_ = f.write(select_snippet(yaml_snippets, "pre-commit-config", subs))
https://redd.it/1ow5vr4
@r_vim
Reddit
From the vim community on Reddit
Explore this post and more from the vim community
How many of those are default Vim bindings?
Been using Vim for not too long and still haven't memorised all the wonderful keybinds.
Just found out that TIC80's code editor has a Vim mode. Can someone more experienced in Vim than me take a look at this and tell me how many of them are default/common Vim binds, and how many are "close approximations" or "cursed" even?
Keep in mind this is a tiny fantasy console with a very simple editor. So, of course, its Vim mode is very minimal.
The main thing I can see is that due to lack of motions, some stuff in N mode, such as delete or yank, just operate on the full line immediately.
The keybinds in question:
Motion Keys
Work in both normal and select mode.
Normal Mode
Select Mode
https://redd.it/1owmv4o
@r_vim
Been using Vim for not too long and still haven't memorised all the wonderful keybinds.
Just found out that TIC80's code editor has a Vim mode. Can someone more experienced in Vim than me take a look at this and tell me how many of them are default/common Vim binds, and how many are "close approximations" or "cursed" even?
Keep in mind this is a tiny fantasy console with a very simple editor. So, of course, its Vim mode is very minimal.
The main thing I can see is that due to lack of motions, some stuff in N mode, such as delete or yank, just operate on the full line immediately.
The keybinds in question:
Motion Keys
Work in both normal and select mode.
h - left one column
k - up one row
j - down one row
l - right one column
(arrow keys also work)
g - start of file
G - end of file
0,Home - start of line
$,End - end of line
ctrl+u,pageup - up one screen
ctrl+d,pagedown - down one screen
K - up half screen
J - down half screen
b - back one word
w - forward one word
^ - first non-whitespace character on line
{ - next empty line above current position
} - next empty line below current position
% - jump to matching delimiter
f - seek forward in line to next character typed
F - seek backward in line to next character typed
; - seek forward in line to next character under cursor
: - seek backwards in line to next character under cursor
Normal Mode
escape - exit editor to console
i - enter insert mode
a - move right one column and enter insert mode
o - insert a new line below current line and enter insert mode on that line
O - insert a new line above current line and enter insert mode on that line
space - create a new line under the current line
shift+space - create a new line above the current line
v - enter select mode (visual mode from vi)
/ - find
n - go to next occurance of found word
N - go to previous occurance of found word
# - go to next occurance of word under cursor
r - find and replace
u - undo
U - redo
p - paste, will place multi line blocks of code on line below
P - paste, will place multi line blocks of code above current line
1-9 - goto line, just type the line number and it will take you there
[ - go to function definition if it can be found
? - open code outline
m - mark current line
M - open bookmark list
, - goto previous bookmark
. - goto next bookmark
z - recenter screen
-(minus) - comment line
x - delete character under cursor
~ - toggle case of character under cursor
d - cut current line
y - copy current line
W - save project
R - run game
c - delete word under cursor and enter insert mode
if over a delimiter or quotation, delete contents contained and enter insert mode
C - delete until the end of the line and enter insert mode
> - indent line
< - dedent line
alt + f - toggle font size
alt + s - toggle font shadow
Select Mode
escape - switch to normal mode
-(minus) - comment block
y - copy block
d - cut block
p - paste over block
c - delete block and enter insert mode
> - indent block
< - dedent block
/ - find populating current selection
r - find and replace within block
~ - toggle case in block
https://redd.it/1owmv4o
@r_vim
Reddit
From the vim community on Reddit
Explore this post and more from the vim community
Cyclops.vim - a new approach for creating dot (or pair ; ,) repeatable operators
This is an idea I had a few years ago to enable dot repeat functionality to existing operators without requiring plugin-side changes. Configuration is minimal, just one line to define a new map:
nmap <expr> / dot#Noremap('/')
Or if the map already exists, there is a helper function to redefine it:
call dot#SetMaps('nmap', 'a')
Unlike other plugins, there is no plugin-side changes needed, and it doesn't constantly record macros. It works on operators that require input, as well ones that don't.
Cyclops.vim works via a REPL pattern, the plugin concatenates a probe character to the end of the managed operator to detect if input is required, then stores the input for later use when repeating. It makes use of the
Additionally, pair repeating with
cyclops.vim
https://redd.it/1oxxka3
@r_vim
This is an idea I had a few years ago to enable dot repeat functionality to existing operators without requiring plugin-side changes. Configuration is minimal, just one line to define a new map:
nmap <expr> / dot#Noremap('/')
Or if the map already exists, there is a helper function to redefine it:
call dot#SetMaps('nmap', 'a')
Unlike other plugins, there is no plugin-side changes needed, and it doesn't constantly record macros. It works on operators that require input, as well ones that don't.
Cyclops.vim works via a REPL pattern, the plugin concatenates a probe character to the end of the managed operator to detect if input is required, then stores the input for later use when repeating. It makes use of the
operatorfunc to not collide with the built in dot repeat behavior.Additionally, pair repeating with
; and , is also included. By default, f, F, t, T maps are provided to retain expected behavior. Pair repeating is configured similarly and uses the same machinery as dot repeating. Pair repeating does not impact dot repeating and vice versa.cyclops.vim
https://redd.it/1oxxka3
@r_vim
GitHub
GitHub - numEricL/cyclops.vim: The simplest method of adding repetition to your maps and operators
The simplest method of adding repetition to your maps and operators - numEricL/cyclops.vim
I just want to use this old (bitmap?) font
I have this struggle with every modern IDE, text editor, etc. I'm in love with the old Courier font and how it was displayed on Windows 95/98/2k/XP, but I haven't been able to reproduce this style. It's not the font per se, it's not a Courier vs Courier New thing. I think it's because Courier in modern systems is rendered in a a different way.
Any one knows how to render it like in the old times? I'm using linux. Maybe some terminal emulator different than the ones provided in Mate or XFCE?
I'm talking about this:
Best programming font ever.
Nedit does font rendering the way I want. But it hasn't the Vim or Emacs movement so I feel like stuck in notepad.
https://redd.it/1oycbjo
@r_vim
I have this struggle with every modern IDE, text editor, etc. I'm in love with the old Courier font and how it was displayed on Windows 95/98/2k/XP, but I haven't been able to reproduce this style. It's not the font per se, it's not a Courier vs Courier New thing. I think it's because Courier in modern systems is rendered in a a different way.
Any one knows how to render it like in the old times? I'm using linux. Maybe some terminal emulator different than the ones provided in Mate or XFCE?
I'm talking about this:
Best programming font ever.
Nedit does font rendering the way I want. But it hasn't the Vim or Emacs movement so I feel like stuck in notepad.
https://redd.it/1oycbjo
@r_vim
How to display images in Vim while note-taking with vimwiki?
I'm currently trying to migrate from Obsidian to vimwiki in Vim (not Neovim) for note-taking. I'd prefer to stick with Vim rather than switching to Neovim if possible. I'd like to display images when navigating through links, but the markdown viewers I've tried don't seem well-suited for link navigation in vimwiki. Does anyone have suggestions for displaying images inline or alongside Vim while maintaining smooth wiki link navigation? I'm looking for something that works well with vimwiki's link-following workflow. Coming from Obsidian, I'm used to seeing images embedded in my notes, so I'm hoping to replicate some of that experience in Vim.
https://redd.it/1ozhw3y
@r_vim
I'm currently trying to migrate from Obsidian to vimwiki in Vim (not Neovim) for note-taking. I'd prefer to stick with Vim rather than switching to Neovim if possible. I'd like to display images when navigating through links, but the markdown viewers I've tried don't seem well-suited for link navigation in vimwiki. Does anyone have suggestions for displaying images inline or alongside Vim while maintaining smooth wiki link navigation? I'm looking for something that works well with vimwiki's link-following workflow. Coming from Obsidian, I'm used to seeing images embedded in my notes, so I'm hoping to replicate some of that experience in Vim.
https://redd.it/1ozhw3y
@r_vim
Reddit
From the vim community on Reddit
Explore this post and more from the vim community
I made a small tool to run Vim inside Dev Containers: devcontainer.vim
I often work with Dev Containers, but I still prefer using Vim in my terminal.
To bridge that gap, I made a small command-line tool called devcontainer.vim
It’s a small helper, but it makes my workflow smoother when launch container.
Just sharing in case someone else finds it useful.
https://github.com/mikoto2000/devcontainer.vim
https://redd.it/1ozbxvk
@r_vim
I often work with Dev Containers, but I still prefer using Vim in my terminal.
To bridge that gap, I made a small command-line tool called devcontainer.vim
It’s a small helper, but it makes my workflow smoother when launch container.
Just sharing in case someone else finds it useful.
https://github.com/mikoto2000/devcontainer.vim
https://redd.it/1ozbxvk
@r_vim
GitHub
GitHub - mikoto2000/devcontainer.vim: VSCode Dev Container の Vim/NeoVim 版。 VSCode 向けに作成された devcontainer.json とは別に、後付け設定ファイルを追加するだけで…
VSCode Dev Container の Vim/NeoVim 版。 VSCode 向けに作成された devcontainer.json とは別に、後付け設定ファイルを追加するだけで Vim による Dev Container 開発が可能になることを目指しています。 - mikoto2000/devcontainer.vim
github-actions.vim
Howdy r/vim
Wanted to share another pure vim9noscript plugin I'm working on to help with a regular part of my daily work: github-actions.vim
The plugin leverages `gh cli` to let you list Workflows, workflow run details, open workflow files / view the details on GitHub.
# Why I built it
I've been pairing with DevOps folks in my org and was pretty impressed by the VSCode GitHub Actions extension. Rather than opening the IDE I decided it would be easy enough to port the functionality into vim and save my sanity
# Screenshot + Quick Demo
(https://preview.redd.it/pp8uwdad3r1g1.png?width=1283&format=png&auto=webp&s=5b4f2f4dbae0c1645f82566eb42b60d7d8388330)
https://preview.redd.it/gzyz2g136r1g1.png?width=1291&format=png&auto=webp&s=3641192ec7bfc58dd824d7bed23ae19c78c5d058
# Current Status
v1.0.0 release is in a good place but there are a few more features I'd like to add here soon (last actions in current branch, delete workflow definitions).
I'd love any feedback / questions / feature suggestions you might have.
Repo: https://github.com/DanBradbury/github-actions.vim
https://redd.it/1oz81oh
@r_vim
Howdy r/vim
Wanted to share another pure vim9noscript plugin I'm working on to help with a regular part of my daily work: github-actions.vim
The plugin leverages `gh cli` to let you list Workflows, workflow run details, open workflow files / view the details on GitHub.
# Why I built it
I've been pairing with DevOps folks in my org and was pretty impressed by the VSCode GitHub Actions extension. Rather than opening the IDE I decided it would be easy enough to port the functionality into vim and save my sanity
# Screenshot + Quick Demo
(https://preview.redd.it/pp8uwdad3r1g1.png?width=1283&format=png&auto=webp&s=5b4f2f4dbae0c1645f82566eb42b60d7d8388330)
https://preview.redd.it/gzyz2g136r1g1.png?width=1291&format=png&auto=webp&s=3641192ec7bfc58dd824d7bed23ae19c78c5d058
# Current Status
v1.0.0 release is in a good place but there are a few more features I'd like to add here soon (last actions in current branch, delete workflow definitions).
I'd love any feedback / questions / feature suggestions you might have.
Repo: https://github.com/DanBradbury/github-actions.vim
https://redd.it/1oz81oh
@r_vim
Reddit
VIM - Vi IMproved
The place for questions and conversation on the Vim editor
Repeat last command in terminal buffer
Hey!
I have been using terminal buffers for a while now to mostly compile and execute applications. I have been told Im a disgrace to the Unix world for not using Ctrl-Z and fg, but I prefer seeing what tests failed/where my compile time errors are.
Since I'm usually using multiple buffers at once, navigating to the terminal is often slow. My solution was using tabs for a while but in all honesty, I do not think that this is the real solution for that. So I wonder how one could execute the last command entered in the terminal or even better, even search the last commands of the terminal. I usually have one terminal buffer open, but one could make it more generic and say that execute the last command in the last used terminal buffer.
Is there a native way of doing this? Or do I have to do some trickery with Lua/Vimnoscript?
Cheers
https://redd.it/1p06i05
@r_vim
Hey!
I have been using terminal buffers for a while now to mostly compile and execute applications. I have been told Im a disgrace to the Unix world for not using Ctrl-Z and fg, but I prefer seeing what tests failed/where my compile time errors are.
Since I'm usually using multiple buffers at once, navigating to the terminal is often slow. My solution was using tabs for a while but in all honesty, I do not think that this is the real solution for that. So I wonder how one could execute the last command entered in the terminal or even better, even search the last commands of the terminal. I usually have one terminal buffer open, but one could make it more generic and say that execute the last command in the last used terminal buffer.
Is there a native way of doing this? Or do I have to do some trickery with Lua/Vimnoscript?
Cheers
https://redd.it/1p06i05
@r_vim
Reddit
From the vim community on Reddit
Explore this post and more from the vim community
Section movement ( ]] & [ ) does not count
I open a markdown file that looks like this:
> # HEADING 1
body text
# HEADING 2
body text
body text
# HEADING 3
body text
# HEADING 4
body text
body text
My cursor is at HEADING 1, and i enter `3]
I don't totally understand exclusive or exclusive-linewise motion but it doesn't seem to have anything to do with what I'm asking. I'm thinking this is something i have to configure myself but i feel like i'm missing something obvious.
[https://redd.it/1p0aqyz
@r_vim
I open a markdown file that looks like this:
> # HEADING 1
body text
# HEADING 2
body text
body text
# HEADING 3
body text
# HEADING 4
body text
body text
My cursor is at HEADING 1, and i enter `3]
. Now my cursor is at HEADING 2. Shouldn't it be at HEADING 4? Similarly, if my cursor is at HEADING 4 and i enter 2[`, i expect it to be at HEADING 2, but it ends up at HEADING 3. Do `] and [` only count under certain conditions? I don't totally understand exclusive or exclusive-linewise motion but it doesn't seem to have anything to do with what I'm asking. I'm thinking this is something i have to configure myself but i feel like i'm missing something obvious.
[https://redd.it/1p0aqyz
@r_vim
Reddit
From the vim community on Reddit
Explore this post and more from the vim community
Is vim really good for writing though?
I've been wanting to ditch Obsidian and VsCode in favor of an in-terminal editor for ages and I keep hearing about how great Vim is great for writing.
And I gotta say, after having used it on and off for about two months - I don't get it. I just don't.
I feel like I'm living some crazy alternate reality or something. Almost everything people say Vim does better than GUI editors, I find to be cumbersome and counterintuitive.
Also really not trying to dismissive or anything here. These are my genuine impressions. I WANT to love Vim so please tell me if I just need to push on and wait for it to click.
# I actually feel that Vim is slow for most writing relating actions
Okay, super quick example. Let's say I misspelled a word on the line above. To fix it in Vim, I'd have to:
`<esp>` to exit editing mode (or jk in my case, but whatever)
`b` \- to jump to the beginning of the word
retype word
`i` to re-enter insert mode
That’s six separate actions and nine physical keystrokes, all while remembering which mode you’re in. Meanwhile, in any GUI editor it's gonna be four strokes at most: up, ctrl-shift-left to mark the word, type, down again.
And the difference matters because when you’re writing prose, losing your flow to perform a ritual of motions and jumping between modes really breaks your concentration. At least to me.
# what do you mean ergonomic? What do you mean homerow?
Sitting on my TLK keyboard, I literally have my left hand resting on the modifier keys (ctrl, shift) and my other on the arrow keys. I find that I can usually hit ctrl-shift which are the two most common modifiers without moving my fingers.
Reaching all the arrow keys is a bit more difficult, but writing prose, most of the time you're just going to back-navigate with the left arrow key (your right hand is already gonna be resting on it on most keyboards) and then hit home to get yourself back. Plus, must keyboards these days have programmable layers making it even easier.
The biggest problem I have Vim is that I often have to reach for shift with my pinky and use the number row to perform very basic forms of navigation ($, 0, (, ). etc).
# a lot of the reasons for using vim has nothing to do with vim
When people tell me how great Vim is for writing, they rarely talk about Vim’s modal editing. Instead, they praise:
distraction-free full-screen writing
Markdown support
the plugin ecosystem
how easy it is to pipe things to the terminal
fuzzy searching
Lua config
no mouse required
And yes — all of that is great. But none of that is uniquely Vim.
You can get all of this in Helix, Zed, Sublime, VS Code, even Obsidian with the right plugins.
So why are these arguments for Vim when you can get it in most editors? I don't get it.
# Also, are any of you Vim writers actually using vim to write. Be honest?
I'm not talking about coding. I'm talking about taking notes. Writing prose. Writing docs.
Because I follow a lot of streamers and youtubers who talk about how great Vim is for productivity, and I see most of them switching to Obsidian or even freaking LibreOffice to write their youtube noscripts on stream.
Won't call out any names. just saying. If it's so clearly superior - why not use it?
# Finally...
Don't get me wrong. I love the idea of Vim. Distraction-free terminal writing. I really wish I could love it. But I almost feel that people aren't being honest with themselves when they talk about how much better it is than GUI editors.
Look, if you just like Vim and think it's fun. That's great. In fact, it is fun. I just don't see how it's necessarily better.
Also, I actually really like Vim for coding. So that's why I specifically talked about writing in this post.
https://redd.it/1p0s86r
@r_vim
I've been wanting to ditch Obsidian and VsCode in favor of an in-terminal editor for ages and I keep hearing about how great Vim is great for writing.
And I gotta say, after having used it on and off for about two months - I don't get it. I just don't.
I feel like I'm living some crazy alternate reality or something. Almost everything people say Vim does better than GUI editors, I find to be cumbersome and counterintuitive.
Also really not trying to dismissive or anything here. These are my genuine impressions. I WANT to love Vim so please tell me if I just need to push on and wait for it to click.
# I actually feel that Vim is slow for most writing relating actions
Okay, super quick example. Let's say I misspelled a word on the line above. To fix it in Vim, I'd have to:
`<esp>` to exit editing mode (or jk in my case, but whatever)
gk \- jump up one visual line`b` \- to jump to the beginning of the word
daw \- to delete itretype word
gj to go back down`i` to re-enter insert mode
That’s six separate actions and nine physical keystrokes, all while remembering which mode you’re in. Meanwhile, in any GUI editor it's gonna be four strokes at most: up, ctrl-shift-left to mark the word, type, down again.
And the difference matters because when you’re writing prose, losing your flow to perform a ritual of motions and jumping between modes really breaks your concentration. At least to me.
# what do you mean ergonomic? What do you mean homerow?
Sitting on my TLK keyboard, I literally have my left hand resting on the modifier keys (ctrl, shift) and my other on the arrow keys. I find that I can usually hit ctrl-shift which are the two most common modifiers without moving my fingers.
Reaching all the arrow keys is a bit more difficult, but writing prose, most of the time you're just going to back-navigate with the left arrow key (your right hand is already gonna be resting on it on most keyboards) and then hit home to get yourself back. Plus, must keyboards these days have programmable layers making it even easier.
The biggest problem I have Vim is that I often have to reach for shift with my pinky and use the number row to perform very basic forms of navigation ($, 0, (, ). etc).
# a lot of the reasons for using vim has nothing to do with vim
When people tell me how great Vim is for writing, they rarely talk about Vim’s modal editing. Instead, they praise:
distraction-free full-screen writing
Markdown support
the plugin ecosystem
how easy it is to pipe things to the terminal
fuzzy searching
Lua config
no mouse required
And yes — all of that is great. But none of that is uniquely Vim.
You can get all of this in Helix, Zed, Sublime, VS Code, even Obsidian with the right plugins.
So why are these arguments for Vim when you can get it in most editors? I don't get it.
# Also, are any of you Vim writers actually using vim to write. Be honest?
I'm not talking about coding. I'm talking about taking notes. Writing prose. Writing docs.
Because I follow a lot of streamers and youtubers who talk about how great Vim is for productivity, and I see most of them switching to Obsidian or even freaking LibreOffice to write their youtube noscripts on stream.
Won't call out any names. just saying. If it's so clearly superior - why not use it?
# Finally...
Don't get me wrong. I love the idea of Vim. Distraction-free terminal writing. I really wish I could love it. But I almost feel that people aren't being honest with themselves when they talk about how much better it is than GUI editors.
Look, if you just like Vim and think it's fun. That's great. In fact, it is fun. I just don't see how it's necessarily better.
Also, I actually really like Vim for coding. So that's why I specifically talked about writing in this post.
https://redd.it/1p0s86r
@r_vim
Reddit
From the vim community on Reddit
Explore this post and more from the vim community