Log
- 2/18/2023 - Found good reasoning and explanation of syntax highlights for vim here
- 2/25/2023 - Great advanced vim resource especially vimscripting here
- 3/02/2023 - Cool new tricks in this 14-minute MAKC Youtube video titled “My Favorite Vim Tricks”. Outline:
- Tabs, Custom Workspaces, Multi-language Spell Checking, (auto) completon Ctrl-p/n, File Explorers, Visual Block mode, Macros
- 3/03/2023 - From The Valuable Dev. A Vim Guide for Advanced Users … part of series.
- 3/03 - Vim Tips for the Intermediate Vim User By Jemma Issroff, starts with talking about mini-golf and then starts goes into interesting examples.
- 3/04 - From this Hacker News comment
- Best user manual and guide with examples is built into the editor.
- Table of contents accessible via :h user_toc.txt
- Reference Manual accessible via :h reference_toc
- Cheatsheet accessible via :h quickref
- 3/05 Famous Stackover Flow answer from 8/09/2009–epic explanation about how to grok vi.
- From same thread is this answer from 2010 which has a ton of shortcuts, a starter .vimrc file etc.
- 3/10 Figured out proper autocommands to change colorscheme based on Insert or Command mode.
- 3/11 Decide which new colorschemes to add. Partially inspired by this YouTube video
- 3/12 Successfully followed these instructions to install vim-plug
- Also installed dracula, codedark, and personal favorite: Kolor.
- 3/21 Lots of progress documented in OneNote. For autocomplete based on other words in the document, go into Insert mode and try Ctrl-n and Ctrl-p. For more, see this help doc or this help doc
- 3/23 Delighted by typing ci{ or di{ where i refers to “inside” and you can (c)hange or (d)elete everything inside those curly braces.
- Works for ci* where * = parentheses, quotes, brackets, curly braces, any open/closed tokens.
- 3/25 Need to rewatch this video on g commands. Off the top of my head:
- gj and gk in the context of a long line of text which appears visually as a single paragraph allows one to move up and down within that paragraph without going to different lines
- Also works by adding movement so g5j will move 5 lines down within the visual block of text
- gu [text object] makes everything lowercase. gU [text object] makes everything uppercase.
- e.g., gu$ makes everything lowercase to the end of the line.
- e.g., gU5w makes the next 5 words uppercase
- gj and gk in the context of a long line of text which appears visually as a single paragraph allows one to move up and down within that paragraph without going to different lines
- 5/04 List of vim-friendly apps and utilities and associated HN thread
- 7/11 Vim’s implementation of grep. Some links discussing various flavors of regex related to perl, vim, Basic Regular Expression (BRE) synatx, Extended Regular Expression (ERE) synatx, etc.
- Very short comparison of regex flavors from this Guide to regex in vim
- Stack overflow question from 2010. See this comment and also use vim :help perl-patterns
- vim’s regex mode, invoked by prepending with \v. See vim :help /\v
- See also vim :help pattern
- 8/05 - Creator and maintainer of vim Bram Moolenaar passed away. :( HN thread with personal anecdotes
- 8/27 - Created distinct page for my sed notes
9/16/2023
- Got back into vim-plug because I want to have proper *.astro syntax highlighting. Referencing the vim-astro plugin. Adapted instructions from this Linux vim-plug guide. Main steps: (1) add a new line to
.vimrc
; (2) start new terminal window; and (3) Open a vim file and type:PlugInstall
. - I also edited my
.gitignore
file within/proj-4/a2-astro
so that temporary vim files like*.swp
and*.swo
are not tracked/pushed by git, per these instructions- Should read more about how .gitignore works
- Note. I currently am able to indent pretty effectively with the
ctrl-v
, select how many rows withj
,shift-I
, type text or tabs to apply to all lines sequence. However, deletion (aka outdenting) doesn’t seem to work to well. Reread section 5 Blockwise operators to see if I can fix this.- Another potential resource
9/24/2023
- to switch immediately to tab number ‘n’, type
ngt
. e.g, to move to tab 5, type5gt
. - when invoking vim on the command line, typing
vim -p filename1.txt filename2.txt
will automatically open desired files all at once, each in its own tab all in the same instance of vim.
9/27/2023
- Very handy way of deleting to a
search string
e.g., ‘Nashville’. Instead of typingdtN
, typed/Nashville
followed byor `Enter` key. See [this answer](https://vi.stackexchange.com/questions/14459/delete-to-next-search-result) - Note that to search backwards,
Shift-/
aka?
works just like usual reverse search. e.g., instead of typingdTN
, typed?Nashville
followed byor `Enter` key.
10/11/2023
- vim has a built in sort utility works very well. If you want to sort all lines
:%sort u
. For more see this article
2/05/2024
- Notes on
qq
macro recordings can be found in a7 > History of Technology section > Pasquinelli Chapter 2 aka54-pas-chap2
. - Notes on new
qq
macro recordings can be found in a7 > Eng > Part II Diallectics aka72-p2
.
2/06/2024
- This is how you paste into the
:
command line, officially called the Ex command line. Add something to the default register usingy
for yank, e.g.,yl
for 1 letter,yw
for 1 word.- e.g.,
yb
for one word backward - Then, go to ex cmd line by typing
and typing `:` <Ctrl> + r
and then type ” to access the default register- Can type
"a
to access the a register
- e.g.,
- For more detailed instructions in how to enter in escape/control characters, see this comment
2/15/2024
- Began thinking of transitioning from vim to Neovim. See comparisons in this Baeldung Linux article
6/25/2024
- When using the
:%s
regex, remember that\n
refers to the newlines in the search field, and\r
refers to newlines in the replace field.- So for example, if you want to replace text <newline> with text ; <newline>, you would type
%s|\n|;\r|gc
.
- So for example, if you want to replace text <newline> with text ; <newline>, you would type
- Use this article to understand how to add and retrieve characters from registers. For cut and paste.
- For example, to add everyting from the cursor to the end of the line
$
to the registera
, type"ay$
. B/c y = (y)ank and $ indicates the end of the current line. - Then, to paste what’s in the register
a
, simply type"ap
.
- For example, to add everyting from the cursor to the end of the line
7/07/2024
- Repeated instructions on how to store and paste with register
Example 1
- to yank next 3 words and store in register a, type
"ay3w
. - to paste item in register a, type
"ap
.Example 2
- to yank from current cursor to end of line and store in register b, type
"by$
. - to paste item in register b, type
"bp
.
7/09/2024
- Equivalent to Save As… in macOS / Windows / Office. Type
:w {pathname}/{NEW filename}
will write current file contents into the NEW file. Note that this does not save current contents into the current file so you must type:w
separately to make sure that happens. See more here.
8/03/2024
- Let’s install LSP server and relevant plugins for syntax highlighting snd CoC code completion for TypeScript and React
- Note:
:bd
in vim clears the current buffer (aka closes the window like if you are in PlugInstall) without quitting vim. Before this, I was using:q
to quit vim entirely to clear away PlugInstall. For more, see Stack Overflow
Steps
- Watched this YouTube video by Nir Lichtman at 51 seconds. You can see his .vimrc file at GitHub
- Edit my own
.vimrc
file - Make sure these plug-ins are included within the
call plug#begin( expand() )
andcall plug#end()
lines.
Plug 'prabirshrestha/vim-lsp'
Plug 'mattn/vim-lsp-settings'
- Hm. Looks like I may need to upgrade my version of vim which is currently at 9.0. But CoC requires 9.0.0438 per these instructions.
- So I will use brew to update my vim. Currently using default that came with macOS, stored in
/usr/bin/vim
. - Went through
brew update; doctor; upgrade
cycle for all machines. - Now installing vim using
brew install vim
. For more context, see the Homebrew vim page - Success. Now, running updated vim version 9.1 (02 Jan 2024)
- On x86, running from the
/usr/local/bin/vim
directory . - On arm64 Apple Silicon, running from the
/opt/homebrew/bin/vim
directory .
- On x86, running from the
More steps
- Open up vim, and run plug install with
:PlugInstall
and choose Yes to install the new vim plugins. - Next time you open up any particular filetype with a
*.c
,*.js
,*.ts
, etc. type :LspInstallServer and pressY
for yes. This will ensure that the desired Language Server is installed. - To disable everything, just go to the .vimrc file and comment out the 2 lines for the lsp plugins: prabir…/vim-lisp
and
mattn/vim-lsp-settings`. - No need to rerun :PlugInstall, uninstall, etc, it will all be turned off.
- Also, looks like there is a TypeScript LSP that automatically pops up when I open
*.js
files. But not any default JS Lsp’s. - Ok got all machines working. Can easily toggle on/off lsp functionality by commenting on/off 2 plugins in
.vimrc
.
8/31/2024
- Let’s install neovim so i can take advantage of code completion etc for TypeScript, Vue, and React projects.
- Reran usual brew hygeine commands, see OneNote
Some tutorials for today’s setup
- Feb 2024 - Ultimate Vim Vue Setup. Vim, not neovim
- Feb 2024- YouTube by Dreams of Code: The perfect Neovim setup for Next.js (it’s back)
Notes on Neovim setup from Dreams of Code tutorial
Part 1: Initial setup
- Installing latest stable build of neovim, release 0.10. In video, they are using 0.9.4.
- Installed with
brew install neovim
- Updated .vimrc file for shortcut for nvim commands
- In addition to installing neovim, need to install git and nerdfonts. Both are installed already.
- Next, go with basic config. DoC recomends NVChad.
- config file usually lives at
~/.config/nvim
- command to clone NVChad:
git clone -b v2.0 https://github.com/NvChad/NvChad ~/.config/nvim --depth 1
- creates ~/.config/nvim directory.
- config file usually lives at
- To quickly switch the color theme, in Cmd mode, just type
<space>th
- CoD recommends ‘catpuccino’ theme
- Because many themes break my macOS Terminal setup, i chose pastelbeans which seems to work OK in both Alacritty and Terminal.
- Also don’t mind decay on iMac display. Note, need to type
:match Error /\t/
to reactivate tab coloring
Part 2: Configuring for JS and TS
- Starting at 2:27, CoD talks about what’s needed.
- LSP install. Navigate to
~/.config/nvim/lua/custom/
- Edit the
.../nvim/lua/custom/chadrc.lua
file. Add these lines below theM.ui = { theme = 'pastelbeans' }
:M.plugins = "custom.plugins" return M
- Edit the
- Create a new plugins.lua file in that location like this:
~/.config/nvim/lua/custom/plugins.lua
- Verify that this is entered into
.../nvim/lua/custom/plugins.lua
. Note that you must edit this file again below to make sure the TypeScript LSP is installed
local plugins = {
{
"neovim/nvim-lspconfig",
config = function()
require "plugins.configs.lspconfig"
end,
}
}
return plugins
- Create a file named lspconfig.lua and store in
.../nvim/lua/custom/configs/lspconfig.lua
and add these contents. Note that this is one level down with a new configs subdirectory!
local base = require("plugins.configs.lspconfig")
local on_attach = base.on_attach
local capabilities = base.capabilities
local lspconfig = require("lspconfig")
lspconfig.tsserver.setup({
on_attach = on_attach,
capabilities = capabilities,
})
- Now to install the TypeScript lsp server. There are 2 ways of doing this:
- Using brew or other package managers on my local machine to download. Or perhaps use the PlugInstall for vim.
- Use the nvim specific installer mason.nvim. Advantage of this method is that this follows our config to another machine. Let’s use mason.nvim.
- So let’s edit
.../nvim/lua/custom/plugins.lua
and add new lines ensuring that the typescript server is installed. Here is the final version of theplugins.lua
file up to this point:
local plugins = {
{
"neovim/nvim-lspconfig",
config = function()
require "plugins.configs.lspconfig"
end,
},
{
"williambowman/mason.nvim",
opts = {
ensure_installed = {
"typescript-language-server",
}
}
}
}
return plugins
- Now, let’s quit nvim and reopen it to reload our plugins.
- Type
:MasonInstallAll
and we will see the LSPs for Lua and Typescript being installed. - After that, autocomplete is ready to go for lua and TS. We can verify this is working by going into any JS or TS file and typing
:LspInfo
which will show that the server is installed. Also, by typing in standard JS/TS keywords will show have autocomplete working.
- Not sure if I need this, but I added
"vue-language-server",
so the complete version of.../nvim/lua/custom/plugins.lua
is:
local plugins = {
{
"neovim/nvim-lspconfig",
config = function()
require "plugins.configs.lspconfig"
end,
},
{
"williambowman/mason.nvim",
opts = {
ensure_installed = {
"typescript-language-server",
"vue-language-server",
}
}
}
}
return plugins
- and also within nvim, typed
:MasonInstall vue-language-server
.Part 3: Instructions on setting up autocomplete for Tailwind.css
- Starts at 6:30
Part 4: Instructions for installing ESlint
- Starts at 7:29
Part 5: Instructions for installing Prettier
- Starts at 10:02
Part 6: Instructions for installing HTML auto tag closers
- Starts at 12:39
9/01/2024
- Commented out legacy LSP plugins from .vimrc because I’m relying on Mason, etc. in NVChad.
- Tried out various new color themes (see OneN).
- On champ, installed vue LSP with command
MasonInstall vue-language-server
. Hopefully this handles most cases and I don’t need to still install volar or tree-sitter
Vim folding
- Based on this article, one can manually fold with
zf{motion}
.- Handy to use this to automatically make indent aware folding (regardless of tabs or spaces).
:setlocal foldmethod=indent
. - After that,
zo
to open a fold andzc
to close a fold, for wherever the cursor is. - At some point, perhaps explore folding based on syntax
:setlocal foldmethod=syntax
- Handy to use this to automatically make indent aware folding (regardless of tabs or spaces).
Relative line numbering isn’t working in Neovim
- I asked phind and got this answer
- Here is what works in my
~/.vimrc
file:
" Turn on absolute line numbers
set number
" Turn on relative iine numbers
set relativenumber
- According to phind, these are the equivalent lines I need to enter into my
~/.config/nvim/init.lua
file:
-- Enable line numbers
vim.opt.number = true
-- Enable relative line numbers
vim.opt.relativenumber = true
9/08/2024
vim relative line numbers
- To toggle between relative line numbers on or off, use ! at end.
set rnu!
shorthand command- :set relativenumber! unabbreviated version
- To turn off/on directly
set rnu
shorthand to turn on- :set relativenumber to turn on (unabbreviated command)
set nornu
shorthand to turn off- :set norelativenumber to turn off (unabbreviated command)
vim absoluteline numbers
- To toggle between having line numbers on or off, use ! at end.
set nu!
shorthand command- :set number! unabbreviated version
- To turn off/on directly
set nu
shorthand to turn on- :set number to turn on (unabbreviated command)
set nonu
shorthand to turn off- :set nonumber to turn off (unabbreviated command)
12/30/2024
- While playing around with tabs/spaces/indents in a Scheme program, two simple commands.
:set ruler
to turn on column/line number display in bottom right.xx |
(pipe) jumps the cursor to the xx column. e.g., to jump to the 24th column on the current line, type23 |
.- Note that column numbers are 1-indexed rather than zero-indexed. So if each tab is 2 spaces, the proper indent for each successive indent is
1, 3, 5, 7, etc.
.
1/25/2025
- Vim / NeoVim plugin by Georgi Gerganov, creator of llama.cpp, whisper.cpp, and many other projects. HN thread, legacy about page which has helpful intro. Latest llama.vim page
- December 2024 paper explaining code completion, benchmarking Fill-In-the-Middle (FIM). FIM gathers context both before and after where the cursor is, in contrast to older methods that only have context of the stuff before the cursor (aka “left to right” prefix-only completion).
2/08/2025
- vim browser links below
- I’ve started playing around with vim motions in the browser, esp. for macOS. First step has been installing the vimari Safari extension. I’ll also try the vimb. Both of the above use WebKit 2.
- I’ll also check the Chrome extension Vimium on Chrome and Firefox. And probably install Qutebrowser to see how I like it. I found the list of Similar Projects on the Qutebrowser site to be very helpful.
- These explorations were encouraged by this vim broswer blog post from 2017 and more recently by ‘A mouseless tale: trying for a keyboard-driven desktop’ with related HN thread.