My own configure files for UNIX/Linux tools.
- Use the command
git clone https://github.com/Kaiser-Yang/dotfiles.git
to clone this repository. - Use the command
cd dotfiles
to enter the directory. Run./dot_files.py init
to installtmux
,fish
,vim
andnvim
. - Use the command
./dot_files.py
to only copy the configuration files to your$HOME
directory. - You need to install
nodejs
andyarn
first (If you use./dot_files.py init
this has been done). - Run
vim
ornvim
to install plugins.
NOTE: Before copying the configuration files to your $HOME
directory, the original files will be backed up to the backup
directory in this repository. You can use ./dot_files.py recover
to recover the original files.
In dot_files.py
, there are two variables:
ignore_file = set(["./.git", "./LICENSE", "./README.md",
"./dot_files.py", "./.gitignore", "./replace_md_image.py",
"./installer", "./vscode-setting", "./README.assets", "./markdownBackup"])
copy_file = set(["./.vimrc", "./.vim", "./.tmux.conf", "./proxy.sh",
"./proxy.fish", "./.config/nvim"])
The files or directories in ignore_file
will not be copied to your $HOME
directory, and the files or directories in copy_file
will be copied to your $HOME
directory. The contents of files which are not in those two sets will be appended to the files in your $HOME
directory.
If you only want to install the configurations of vim
, you just need to add ./.vimrc
and ./.vim
to copy_file
, and add all other directory to ignore_file
. Then run ./dot_files.py
.
If you only want to install the configurations of nvim
, you just need to add ./.config/nvim
to copy_file
, and add all other directory to ignore_file
. Then run ./dot_files.py
.
If you only want to install the configurations of tmux
, you just need to add ./.tmux.conf
to copy_file
, and add all other directory to ignore_file
. Then run ./dot_files.py
.
If you only want to install the configurations of fish
, you just need to add ./proxy.fish
to copy_file
, and add all other directory, except for .config/fish
, to ignore_file
. Then run ./dot_files.py
.
Besides, there are other types parameters you can pass to dot_files.py
:
update
: only update the configurations depending on theignore_file
andcopy_file
. This will backup the original files tobackup
directory first.recover
: recover all files from backup directory to$HOME
directory.init
: install all plugins forvim
andnvim
, and installfish
and setfish
be your default shell.
Indeed, if you run ./dot_files.py
with no parameters, it is same with ./dot_files.py recover && ./dot_files.py update
. So I strongly recommend you to use ./dot_files.py
to update the configurations.
This part will only show the screenshots of nvim
.
There is a file called replace_md_image.py
, this file receive a directory as a parameter, and it will download all the images in the markdown files (recursively) in the directory and replace the image links with the local links. This will backup your markdown files first:
Note that my leader key is Space
.
Note that in the Mode
column, N
means normal mode, I
means insert mode, V
means visual mode, T
means terminal mode, X
means select mode, and N I
means normal mode and insert mode.
Shortcut | Mode | Description |
---|---|---|
Q | N | Quit but not save |
<C-S> | N I | Save but not quit |
S | N | Save and quit |
Shortcut | Mode | Description |
---|---|---|
<LEADER>h | N | Split window horizontally, and move cursor to the left window |
<LEADER>l | N | Split window horizontally, and move cursor to the right window |
<LEADER>t | N | Create a new tab |
<C-H> | N | Move cursor to the next left window |
<C-J> | N | Move cursor to the next down window |
<C-K> | N | Move cursor to the next up window |
<C-L> | N | Move cursor to the next right window |
<LEADER>H | N | Close the current window, and reopen it at left |
<LEADER>J | N | Close the current window, and reopen it at bottom |
<LEADER>K | N | Close the current window, and reopen it at top |
<LEADER>L | N | Close the current window, and reopen it at right |
<LEADER>n | N | Go to next tab |
<LEADER>b | N | Go to previous tab |
<LEADER>1 | N | Go to the first tab |
<LEADER>2 | N | Go to the second tab |
... | ... | ... |
<LEADER>8 | N | Go to the eighth tab |
<LEADER>9 | N | Go to the ninth tab |
Up | N | Resize +5 for the current window |
Down | N | Resize -5 for the current window |
Left | N | Resize -5 vertically for current window |
Right | N | Resize +5 vertically for current window |
NOTE: We can not bind <C-H>
in insert mode, so in the insert mode, when you press <C-H>
, it will trigger backspace.
Shortcut | Mode | Description |
---|---|---|
Y | N | Copy till end of line to unnamed register |
<LEADER>y | N V | Copy to system clipboard, this is like y , for example, you can use <leader>yw to copy a word |
<LEADER>ya | N | Copy all contents in the current buffer to system clipboard |
<LEADER>Y | N | Copy till end of line to system clipboard |
<LEADER>p | N | Paste from system clipboard |
<LEADER>P | N | Paste from system clipboard before cursor |
NOTE: if you want to copy around a bracket, you can use <LEADER>ya
, too. But you need to wait some time when you press <LEADER>y
(make sure that there is "+y
at the right bottom), then you can press a
.
Shortcut | Mode | Description |
---|---|---|
<C-J> | When there is a selection list and j will input letter j, <C-J> will move the cursor to the next selection |
|
<C-K> | When there is a selection list and k will input letter k, <C-K> will move the cursor to the previous selection |
|
j | When there is a selection list and you can not input with j , j will move the cursor to the next selection |
|
k | When there is a selection list and you can not input with k , k will move the cursor to the previous selection |
|
<C-J> | I | When there is no selection list, <C-J> will move the cursor to the next line |
<C-K> | I | When there is no selection list, <C-K> will move the cursor to the previous line |
J | V | Move the selected lines down |
K | V | Move the selected lines up |
Note that when coc
suggestion list is not shown but copilot
is shown, it is possible to use <C-J>
and <C-K>
to move the cursor to the next or previous selection of copilot
.
For example when you use gr
to go to references of a function or a variable, there may be a selection list (if there is not only one reference), and you can use j
and k
to move the cursor to the next or previous selection. But when you use <C-P>
to find files, in this case j
and k
will input letter j and letter k, so you can use <C-J>
and <C-K>
to move the cursor to the next or previous selection.
These settings only work in a markdown file.
Some of the settings below will insert <++>
as a placeholder symbol, and you can use ,f
to move the cursor out of the current block and remove the placeholder symbol.
Shortcut | Mode | Description |
---|---|---|
,f | I | Move the cursor out of the current block and remove next placeholder symbol |
,t | I | Insert command line block and leave the cursor where you can input the command |
,b | I | Insert bold line block and leave the cursor where you can input the bold content |
,m | I | Insert math line block and leave the cursor where you can input the math |
,M | I | Insert math block and leave the cursor where you can input the math |
,c | I | Insert code block, and leave the cursor where you should input the code language |
,n | I | Insert a new line symbol of html |
This part has a lot of shortcuts, and I'll only list some common ones. All the shortcuts started with <LEADER>
, [
or ]
can be seen in vimwhichkey
plugin, which means you just need press <LEADER>
, [
or ]
and wait for a while, there will be pop up window to show all the shortcuts started with the key you press.
Shortcut | Mode | Description |
---|---|---|
<LEADER>c<LEADER> | N | Comment or uncomment the current line, this can be used as 2<LEADER>c<LEADER> to comment or uncomment 2 lines |
<LEADER>c<LEADER> | V | Comment or uncomment the selected line |
<LEADER>cl | N | Comment the current line and align left, this can be used as 2<LEADER>cl to comment 2 lines |
<LEADER>cl | V | Comment the selected lines and align left |
Shortcut | Mode | Description |
---|---|---|
ys | N | Surround something, you can use ysw[ or ysw] to surround a word with [] , and you can use ysf and yst to find or till some character |
yss | N | Surround the whole line with the character you input, this one will put the surrounding in the current line |
ySS | N | Surround the whole line with the character you input, this one will put the surrounding in new lines |
ds | N | Delete the surrounding you input |
cs | N | Change the surround with a new one |
S | V | Surround the selected characters |
<C-B> | I | Back insert a surrounding, when a surrounding does not match, you press the close surrounding, the cursor may jump to the next close surrounding rather than inserting a new close surrounding. In this case, you can use <C-B> to back insert a close surrounding |
Some examples of surrounding:
ysf;{
: surround the character from the cursor to next;
with{}
.yst;{
: surround the character from the cursor till next;
with{}
, this will leave the;
out of the surrounding.ds(
: delete the()
surrounding current part.cs([
: change the()
with[]
for current surrounded part.
NOTE: the difference between ysw[
ans ysw]
is that the former will add white space at left and right, the latter will not.
Shortcut | Mode | Description |
---|---|---|
gd | N | Go to definition |
gr | N | Go to references |
gh | N | Go to the header file |
<LEADER>R | N | Rename the current symbol |
<LEADER>r | N | Run the single file depending on its filetype |
H | N | Quick fix |
]d | N | Go to next diagnostic |
[d | N | Go to previous diagnostic |
<LEADER>d | N | Show document symbols, this can also be used to show variables' types |
Shortcut | Mode | Description |
---|---|---|
C-F | I | Select one line when copilot suggestions are shown |
<ESC>f | I | Select one word when copilot suggestions are shown. In 7-bit terminal press <M-F> will trigger <ESC>f |
<ENTER> | I | Select current suggestion when one coc suggestion is selected |
<ENTER> | I | Select first suggestion when coc is not shown and copilot is shown |
<C-C> | I | Cancel the completion, if coc and copilot are both shown, this will quit coc 's completion |
Shortcut | Mode | Description |
---|---|---|
<C-Q> | N I | Open undo history |
<C-W> | N I | Open outlook |
<C-E> | N I | Open explorer |
<C-P> | N I | Find files in the current directory or a git root directory |
<C-F> | N I | Find contents in the current directory or a git root directory |
<LEADER>a | N | Align a block, : , = and | are supported, for example, you can use <LEADER>a= to align a block of assignments |
Most shortcuts in nvim
are same with those in vim
, therefore, this part will only list the different ones or those only supported in nvim
.
NOTE: I now use nvim
, the vim
part will not be updated any more.
- When the cursor is at a indent line in insert mode, the cursor is hidden by the indent line.
<C-N>
can not back to normal when in replacing mode (after pressingr
). This seems impossible to fix, because when pressr<C-N>
, your key sequence isr<C-N>
(pressingr
will still waiting your input, you can see that through the statusline). ButR
is OK, because pressingR
will let you enterREPLACE
mode, you can use<C-N>
to go back to normal mode.
auto-pairs
may not be loaded when first usenvim
to open a file. When opening another file,auto-pairs
will be loaded.- When you use
:q
to quit the terminal, the terminal cannot be opened again. This is because we will record the terminal's status when you useQ
, but when you use:q
, we will not record the terminal's status. So next time to open the terminal will think the terminal is visible, and hide it, which will trigger a error. The best way to quit the terminal is to useQ
. - When the first time open terminal, it may be wrong highlight. I've disabled the
nvim-treesitter
forfish
andbash
to solve this. - When there is a
.root
directory, thenvim-tree
will enter the root directory rather than the parent directory of.root
. <CR>
can not auto indent.telescope
can not find files and contents if there is a.root
directory.- Pyhton
gd
does not work. - No hover highlight.
- When quit a help file which is editable, this may cause problem.
Shortcut | Mode | Description |
---|---|---|
<C-T> | N I T | Toggle a terminal |
Q | N | Quit a window, quit a tab or unload a buffer, not save |
S | N | Similar with Q , but this will execute 'write' first |
<C-N> | T I V X N | Back to normal mode by <C-\><C-N> |
J | V | Move selected content down, support {count}J |
K | V | Move selected content up, support {count}K |
r | N | Run the current file depends on its filetype, this will onpen a terminal for some filetypes |
NOTE: The Q
's behavior depending on the status. If current buffer is a terminal, nvimtree
, aerial
, or help
, this will use bd!
to unload the buffer. If current tab has more than one window whose buffer is a visible one, Q
will use :quit!
to close window, but not unload the buffer. If there are more than one tab and only one window in current tab, this will close the whole tab and unload the empty noname
buffers and other hidden buffers. If there only one tab, this will unload current buffer.
There will only be one terminal globally, this is for some simply commands, such as run a single python
file or check the cpu
usage by top
or htop
. If you want something complex, you should depend on the tmux
rather than nvim
terminal. Besides, the terminal will auto open when entering a new tab if there has been one open terminal or auto close when entering a new tab if the one has been closed. There only one terminal buffer, so each terminal has same contents.
Shortcut | Mode | Description |
---|---|---|
ys{motion}f{name} | N | Surround the part with a function call |
dsf | N | Delete a function call, only parameters will be left |
csf{name} | N | Change a function call with a new one |
<CR> | N | In file explorer, this will enter a directory or open a file |
<BS> | N | In file explorer, this will go to the .. directory. You can use ? to see more mappings in file explorer. |
gc | N | Open coc-command |
gl | N | Open coc-list |
gy | N | List all the yanked contents |
<LEADER>ay | N | Yank all contents |
<ESC> | I | When use telescope to search, <ESC> will let you back to normal mode |
<ESC> | N | When use telescope to search and you are in normal mode, <ESC> will quit telescope |
<C-C> | I | When use telescope to search and you are in insert mode, <C-C> will quit telescope |
<LEADER>n | N | Go to the right buffer shown in bufline |
<LEADER>b | N | Go to the left buffer shown in bufline |
gpt | N | Toggle copilot-chat window |
gpt | V | Input :CopilotChat , you can use <TAB> to trigger menu list of all commands |
bp | N | Buffer pick |
<C-H> | N T | Move the cursor to the left window, this can jump over tmux |
<C-J> | N T | Move the cursor to the bottom window, this can jump over tmux |
<C-K> | N T | Move the cursor to the top window, this can jump over tmux |
<C-L> | N T | Move the cursor to the right window, this can jump over tmux |
<C-D> | I | Scroll down the completion preview window, if there is one |
<C-U> | I | Scroll up the completion preview window, if there is one |
<C-C> | I | Close all completion when no selection in coc; close coc completion when there is a selection of coc; close copilot completion when coc invisible and copilit visible; back to normal |
If you have any suggestion or find any bug, please feel free to open an issue or pull request.