Skip to content

https: arkadiuszchmura.com posts stop‐perfecting‐your‐config

Songli Yu edited this page Aug 8, 2023 · 1 revision

I think the config is clean enough. It only contains a main file (lua/ysl/init.lua) and some branch file (lua/ysl/**/*.lua).

I don't like mapping too much keys. So I tried my best to keep the original key bindings and use more ex commands.

Some useful stuff here:

==============
=== Global ===
==============
Some terminals (e.g. Bash) follow `emacs` keybindings by default.
`!!`, `!-1`
    Run last command in Bash.
`:messages`
    Show output messages.


=========================
=== Windows & Buffers ===
=========================
`:ls`
    List all buffers.
`:b 3`, `:b3`
    Jump to the 3rd buffer.
`<C-w>T`
    Split current buffer into a whole window. Useful when a window contains many buffers.
`:tab sball`
    Split all buffer file to tabs.
`:bn`, `:bp`
    Next & Previous buffer.
`:bd`
    Delete current buffer.
`:e`
    Open a new file.
`:tabe`
    Open a new file in a new tab.
`:cd %:h`
    Change vim workspace to current file's parent folder.
`:tabo`
    Only keep current tab and delete all others.
`:source %`, `:so %`
    Source current open file as nvim config.
`<C-w>|`, `<C-w>_`, `<C-w>=`
    `<C-w>|` for maxmium a vertical vsplit window. `<C-w>_` for maxmium a horizontal split window. `<C-w>=` for restore equal size.
`split_number C-w C-w`
    Select a split by it's pane number.
    The panes are numbered from top-left to bottom-right with the first one getting the number 1.
    For example to go to split number 3 do this 3 C-w C-w, press Ctrl-w twice.
`:pclose`
    Close preview window.


============
=== Diff ===
============
`:h diff`
    Type this for comprehensive introduction.
    In fact, all you need is `:diffthis`, `:diffoff!`
`:set scrollbind`, `:set noscrollbind`
    Set two (or more) windows scrolled together. But note all the windows need to be set this. So you should type this in all windows you need to scroll together. So you should type this in all the windows you want to scroll together.
`:diffthis`
    Diff two windows. You should type this command in all windows you want to diff.
`:diffoff`, `:diffoff!`
    The first is to let current windows exit diff mode. The second is let all windows to exit diff mode.
`:set diff`, `:set nodiff`
    I don't know how to use it. It seems like a global controller for diff mode.
`:set diffopt=iwhite`
    Ignore whitespace among diff files. You can get more info by `:h diffopt`


======================
=== Visual Command ===
======================
`:normal`
    Use it in visual-line mode. Can run normal mode commands in visual-line mode .


===================
=== File & Pipe ===
===================
`:123`
    Move to the line 123.
`:r !cat temp.txt`
    Read contents from temp.txt and paste them into current line.
`:w !sudo tee %`
    Write current file using sudo.
`:set ff=unix`, `:set ff=dos`, `:set ff=mac`
    Set file format to LF or CRLF.
`put = execute('messages')`
    Put `:messages` text into buffer.
`:let @+ = execute('messages')`
    Put `:messages` text into `+` register.
`:redir @<register><CR>:messages<CR>:redir END<CR>`
    Redirect `:messages` to `<register>` register. Ref: https://gist.github.com/romainl/eae0a260ab9c135390c30cd370c20cd7


================
=== Terminal ===
================
`:term`
    Enter a terminal.
`<C-\><C-n>`
    Exit the terminal.


=============
=== Win32 ===
=============
`./neovideOpenFolder.reg` and `./neovimOpenFolder.reg`:
    Add Neovide / Neovim into right mouse click menu.


================
=== Register ===
================
`<C-r>`
    The following sequence will do what you want, given an already selected block of text:
    - `y` (yank the selected text, into the `"` register by default)
    - `/` (enter search mode)
    - `\` `V`) (optional, enter "very no magic" mode*)
    - `C-r` `"` (insert text from `"` register)
    - `<CR>` (Engage!)
    - "very no magic" mode interprets the following text as plain text instead of as a regex. note however that `\` and `/` are still special and will have to be handled in other ways. If the text does not have any characters considered special, you can skip this step.
`"_d`
    Delete without saving last things into register.
`:reg`
    Show registers list.


===================
=== Normal Mode ===
===================
`r<CR>`
    split a line by inserting a <CR>.