-
-
Notifications
You must be signed in to change notification settings - Fork 329
cool tricks
Here you will find find cool tricks that would not fit in the manual (or no one would read them)
- You can press the key 0 to go the the first character of the line.
- You can visually select all with
ctrl+a
on normal mode. - In NormalNvim the key x doesn't yank. Take advantage of this in cases where you need to delete something before pasting without losing the clipboard.
- You can explore the undo tree with Space+fu.
- You can move to the next matching element with %. We ship a improved version that can be used over anything. Try it!
These keybindings are useful to have a quick overview of the code.
- Move 20%: You can press shift + PageUp/PageDown to move a 20% of the total document.
- Move 42: You can press PageUp/PageDown to move 42 lines. The number of lines will be equal to the visible area.
- Move 7: You can press shift + up/down to move 7 lines.
- Move 1: You can press up/down to move a single line.
When you open a buffer, it is a good practice to check how many lines it has. That way you can mentally calculate how many paginations will take to reach anywhere!
Another good strategy is to memorize the line number of the stops of shift+PageUp/PageDown. That way you can have a good guess of the line number of any point of the buffer.
A tab contains buffers. By using tabs you can separate your buffers by context. For example: You can have a TAB with the buffers of the project you are working on, and then another TAB with your backlog. Then by pressing gt
you can quickly switch between both.
command | Description |
---|---|
:tabnew |
open a new tab |
:tabclose |
closes a tab |
gt | go to the next tab |
g1t | go to the tab 1 |
In practice, by using tabs you can avoid having to run multiple instances on neovim in most scenarios.
By pressing Space + f + b
you get a beautiful UI for search and replace in buffer, which is the same as doing
:%s /foo/bar/gc
but more beautiful.
At the time of writing this, NormalNvim is the only nvim distribution to support the official comment docstrings of most programming languages. Try writing one of these auto completions.
# C#/rust
///
# typescript/javascript/java
/**
# lua
---
# python
"""
It will generate a block similar to this
/**
* What it does.
*
* @param a - Example parameter.
* @returns Something.
*
* @example
* ```
* write me later
* ```
*/
You might be familiar with vim text objects. For example, ciw
stands for change inner word
and you can use it to replace the word under the cursor very quick and easy. Learning these motions is essential to master vim.
Well, apart of the default text objects vim has, we also support the new text objects treesitter has. You can check them here, or in /plugins/3-dev-core.lua
searching for treesitter
.
["ak"] = "@block.outer" -- example: cak → change all block
["ik"] = "@block.inner" -- example: cik → change inner block
["ac"] = "@class.outer" -- example: cac → change all class
["ic"] = "@class.inner" -- example: cic → change inner class
["a?"] = "@conditional.outer" -- example: ca? → change all condition
["i?"] = "@conditional.inner" -- example: ci? → change inner condition
["af"] = "@function.outer" -- example: caf → change all function
["if"] = "@function.inner" -- example: cif → change inner function
["al"] = "@loop.outer" -- example: cal → change all loop
["il"] = "@loop.inner" -- example: cil → change inner loop
["aa"] = "@parameter.outer" -- example: caa → change all argument
["ia"] = "@parameter.inner" -- example: cia → change inner argument
Unlike vim/nvim, treesitter know exactly the kind of object under the cursor, so take advantage of these new text objects and move precisely like never before!
Sessions are automatically saved every time you write a buffer. If you prefer to manage sessions manually you can save/load sessions with <Space> + S