[GH-ISSUE #664] Add a section for general tips and tricks #59871

Closed
opened 2026-07-19 12:13:07 -05:00 by GiteaMirror · 3 comments
Owner

Originally created by @premell on GitHub (Jan 19, 2023).
Original GitHub issue: https://github.com/rockerBOO/awesome-neovim/issues/664

I think it would be awesome to have a section where you can share small code snippets (and maybe just tips?). I think it would be very helpful in the same way awesome-neovim for plugins are awesome. You can have a collection of great tips without having to looking at different reddit threads.

These are some examples of tips you could include. These are just some i found in my config, so you'd obviously have to clean them up and rewrite all in lua:

this is a small function i wrote to paste in place, useful when you want to paste something inside of brackets:

local function paste_without_newlines()
	local regestry_item = vim.api.nvim_eval('@"')
	regestry_item = regestry_item:gsub("^[%s%c]*", "")
	regestry_item = regestry_item:gsub("^[%s%c]*", "")
	regestry_item = regestry_item:gsub("[%s%c]*$", "")
	vim.api.nvim_paste(regestry_item, 1, 1)
end

vim.keymap.set({'n', 'v'}, "<c-p>", function()
	paste_without_newlines()
end, { silent = false })

autocommands, I think alot of smaller plugins could be substitued by these small autocommands, if people just knew about them:

-- highlight 
vim.api.nvim_create_autocmd('TextYankPost', {
   group    = 'bufcheck',
   pattern  = '*',
   callback = function() vim.highlight.on_yank{timeout=150} end })
-- remember last position when opening file
vim.cmd[[
  au BufReadPost * silent! normal! g`"zv
]]

keybindings, some of these are well known, but its still nice to have them in the same place:
use jk for esc,
use space for leaderkey
keymap("v", "p", '"_dP', opts) dont save text you've pasted over

move unusual bindings to make D dd, Y yy and V vv consistent:

vim.cmd([[
  nnoremap Y y$
  nnoremap yy Y
  nnoremap V v$
  nnoremap vv V
  vnoremap yy Y
  vnoremap V v$
  vnoremap vv V
]]

center cursor while jumping between search results:

vim.cmd([[
  noremap n nzz
  noremap N Nzz
]]
Originally created by @premell on GitHub (Jan 19, 2023). Original GitHub issue: https://github.com/rockerBOO/awesome-neovim/issues/664 I think it would be awesome to have a section where you can share small code snippets (and maybe just tips?). I think it would be very helpful in the same way awesome-neovim for plugins are awesome. You can have a collection of great tips without having to looking at different reddit threads. These are some examples of tips you could include. These are just some i found in my config, so you'd obviously have to clean them up and rewrite all in lua: this is a small function i wrote to paste in place, useful when you want to paste something inside of brackets: ```lua local function paste_without_newlines() local regestry_item = vim.api.nvim_eval('@"') regestry_item = regestry_item:gsub("^[%s%c]*", "") regestry_item = regestry_item:gsub("^[%s%c]*", "") regestry_item = regestry_item:gsub("[%s%c]*$", "") vim.api.nvim_paste(regestry_item, 1, 1) end vim.keymap.set({'n', 'v'}, "<c-p>", function() paste_without_newlines() end, { silent = false }) ``` autocommands, I think alot of smaller plugins could be substitued by these small autocommands, if people just knew about them: ```lua -- highlight vim.api.nvim_create_autocmd('TextYankPost', { group = 'bufcheck', pattern = '*', callback = function() vim.highlight.on_yank{timeout=150} end }) ``` ```lua -- remember last position when opening file vim.cmd[[ au BufReadPost * silent! normal! g`"zv ]] ``` keybindings, some of these are well known, but its still nice to have them in the same place: use jk for esc, use space for leaderkey `keymap("v", "p", '"_dP', opts)` dont save text you've pasted over move unusual bindings to make D dd, Y yy and V vv consistent: ```lua vim.cmd([[ nnoremap Y y$ nnoremap yy Y nnoremap V v$ nnoremap vv V vnoremap yy Y vnoremap V v$ vnoremap vv V ]] ``` center cursor while jumping between search results: ```lua vim.cmd([[ noremap n nzz noremap N Nzz ]] ```
Author
Owner

@tversteeg commented on GitHub (Jan 20, 2023):

I like this idea a lot, but I don't think an awesome list is the right place for it. Another repo containing all these tips would be better and we could link to it from this list.

<!-- gh-comment-id:1398655017 --> @tversteeg commented on GitHub (Jan 20, 2023): I like this idea a lot, but I don't think an awesome list is the right place for it. Another repo containing all these tips would be better and we could link to it from this list.
Author
Owner

@gbprod commented on GitHub (Jan 20, 2023):

IMHO, TWIN is a better place for that 🙂

<!-- gh-comment-id:1398852985 --> @gbprod commented on GitHub (Jan 20, 2023): IMHO, [TWIN](https://github.com/phaazon/this-week-in-neovim-contents) is a better place for that 🙂
Author
Owner

@premell commented on GitHub (Jan 20, 2023):

@gbprod TWIN is amazing, but its kind of similar to reddit in that you the information is spread out. Already twin is on week 27, in a few years it will be hundreds. Also the tips cannot be altered, so youd have to add them to the newest TWIN if you want to make the slightest adjustment. Generally a weekly news letter isnt a the best way to store a collection of long term tips and scripts

In your opinion, what is the use of awesome-neovim at all, since TWIN already cover plugins aswell?

<!-- gh-comment-id:1398864288 --> @premell commented on GitHub (Jan 20, 2023): @gbprod TWIN is amazing, but its kind of similar to reddit in that you the information is spread out. Already twin is on week 27, in a few years it will be hundreds. Also the tips cannot be altered, so youd have to add them to the newest TWIN if you want to make the slightest adjustment. Generally a weekly news letter isnt a the best way to store a collection of long term tips and scripts In your opinion, what is the use of awesome-neovim at all, since TWIN already cover plugins aswell?
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/awesome-neovim#59871