architecture docs

This commit is contained in:
hophacker 2021-03-04 16:48:55 +08:00
parent 37a574c32d
commit 4361b0d204
3 changed files with 174 additions and 1015 deletions

View File

@ -1,609 +0,0 @@
# Ruilisi dotfiles
[英文文档 English document](/README.md)
## 环境需求
安装`zsh`, `tmux`, `vim`, `ag`并且zsh设置为你的登录shell:
```sh
chsh -s $(which zsh)
```
## 安装
```sh
bash -c "`curl -fsSL https://raw.githubusercontent.com/ruilisi/dotfiles/master/install.sh`"
```
## Shortcuts
#### Tmux
前缀定义为 `C-A`(简称`PRE`)
**Scroll Mode**
`PRE [`: 进入滚动模式
Shortcut | Function
:-------:|:--------:
`Enter` | 复制文本 |
`]` | 复制滚动模式下的内容 |
#### Vim
* `<L>`: `<localleader>`的缩写, 我们设置为 `\`
**Defined by Us**
Normal Mode
Shortcut | Function
:-------:|:--------:
`C-v` | 视图模式
`C-x C-v`| 从系统粘贴板复制内容
`<L>tp` | 切换粘贴
Visual Mode
Shortcut | Function
:-------:|:--------:
`C-c` | 复制
**Defined by Vim**
Shortcut | Function
:-------:|:--------:
`o` |光标下方插入新的一行
`O` |光标上方插入新的一行
`0` |跳至行首
`$` |跳至行尾
`v` |进入字符选择模式
`x` |删除选中的内容
`V` |进入整行选中模式
`y` |复制选中的内容
`p` |粘贴选中的内容
`Ctrl+u` |往上翻页
`Ctrl+d` |往下翻页
`:w` |保存文件
`:q` |退出Vim
`:/ keyword`|搜索
`n` |跳到下一个搜索到的内容
`N` |跳到上一个搜索到的内容
`w` |往前移动一个单词
`b` |往后移动一个单词
`gg` |移动到文档顶部
`G` |移动到文档底部
`Ctrl+\` |显示(隐藏)文件树
`[spc] c l`|快速注释或解除注释行
`%s key1/key2/g`|将文档中的key1替换为key2
`S-V` | 选中文本
#### vim && markdown
* 安装 `prettier`: `yarn global add prettier``npm install --global prettier`
* 打开vim并进入的命令: `:SPUPdate`
## Q&A
#### 如何在vim中编辑命令行
在编辑命令行期间按esc进入正常模式然后按`C-x C-e`在vim中编辑当前命令行。
#### 安装 iTerm Solarized Colors
YADR 会往iTerm里安装Solarized配色方案。进入Profiles => Colors => Load Presets可以选择Solarized Dark。
#### 用[Karabiner-Elements](https://pqrs.org/osx/karabiner/index.html)来交换caps-lock和escape的位置。
escape键是vim里最常用的键。老式键盘曾拥有Tab一样大的键Apple键盘最差的地方就是拥有极小的Esc键。但是
通过交换Esc键和Caps键的位置可以修复这些问题。如果总是不停地敲击角落上的小目标你肯定会大幅降低自己的效率说不定还会让你的手因屡次肌肉用力产生小的创伤。
#### 为iTerm设置一个系统级别的热键 (Keys=>Hotkey)
推荐Cmd-Escape, 实际上就是Cmd-Capslock(因为键的位置互换了)。
#### 在iTerm的General里, 取选 "Use Lion-style full screen"
这可以给你一个可以切换却无需通过切换空间的大屏。
#### 在MacVim的Advanced Settings里, 取消Prefer native fullscreen
和iTerm一样。Lion风格的空间切换会毫无理由地让一切效率降低下来。
## 如果你想在终端上运行
- 确定你的终端已经安装了Solarized配色方案
- 如果你不想用solarized配色的终端, 那就确认你这么做哦了:```
let g:yadr_using_unsolarized_terminal = 1
# in ~/.vimrc.before
```
- 如果你想用一个替代的配色方案譬如Gruvbox, 那就在你的`~/.vimrc.after` 这么做:```
let g:yadr_disable_solarized_enhancements = 1
colorscheme base16-twilight
```
### 升级
升级非常简单。
```bash
cd ~/.yadr
git pull --rebase
rake update
```
## 哪些东西被包括了,如何配置?
继续阅读了解更多YADR给你提供的
### [Homebrew](http://mxcl.github.com/homebrew/)
Homebrew是_缺失了的OSX包管理系统_它会被自动安装。
我们自动安装了一些常用的包例如ctags, git, macvim, hub, 以及RipGrep ('rg')。
注意我们的自动补全插件需要MacVim支持Lua。安装器知道如何安装但如果你以前安装过你需要手动删除你以前的MacVim。
### ZSH
把Zsh想象成一个更加牛逼的Bash却又无需太多学习成本。它会为你写的命令行作自动拼写矫正语法高亮以及更多。
我们并且还增加了很多增强性能:
- Vim模式和bash风格的历史反查询: `Ctrl-R`
- 插入上一行命令的结果: `Ctrl-x,Ctrl-l`
- 模糊匹配 - 如果你打错了文件夹名tab补全会修正它。
- [fasd](https://github.com/clvv/fasd) 集成 - 输入 `z` 会帮你半自动匹配最近用过的文件夹。Tab补全也开启了。
- [Prezto - YADR's背后的zsh](http://github.com/sorin-ionescu/prezto)
- [如何添加你自己的ZSH主题](doc/zsh/themes.md)
### 别名
大部分我们每天用的东西都可以用两到三个字符的别名完成。请自行修改他们:
```
ae # alias 编辑
ar # alias 重载
```
### Git定制化:
YADR会接管你的`~/.gitconfig`, 所以如果你想存储你的git用户名及其他设置, 请把他们放在`~/.gitconfig.user`
我们推荐在这个文件里设置你的用户信息是。另外,你可以将你的环境变量恰当地设置在你的 `~/.secrets`里。
快捷键 | 命令
:-------:|:--------:
`ga` |`git add`
`gb` |`git branch`
`gbc` or `gnb` |`git checkout -b`
`gbs` |`git show-branch`
`gc` |`git commit --verbose`
`gco` |`git checkout`
`gcp` |`git cherry-pick --ff`
`gd` |`git diff`
`gf` |`git fetch`
`gfc` |`git clone`
`gfm` |`git pull`
`gfr` |`git pull --rebase`
`gl` |`git log`
`gpc` |`git push --set-upstream origin "$(git-branch-current 2> /dev/null)"`
`gr` |`git rebase`
`gra` |`git rebase --abort`
`grc` |`git rebase --continue`
`grs` |`git rebase --skip`
`gsd` |`git stash drop`
`gsl` |`git stash list`
`gsp` |`git stash pop`
`gst` |`git stash`
##### vim-gitgutter
- `]h` 下一个hunk(更改点)
- `[h` 上一个hunk
- `<Leader>ha` 将该hunk放进state区域保存
- `<Leader>hr` 撤销该hunk
### RubyGems
.gemrc被包含了。 再也不用输入`gem install whatever --no-ri --no-rdoc`. `--no-ri --no-rdoc`,因为默认都做好哦了。
### Tmux 设置
`tmux.conf` 为Mac OS上的tmux提供了一些合情合理的默认设置例如强大的状态条和VIM键盘绑定。
你可以在`~/.tmux.conf.user`修改配置。
### 让所有的东西都Vim风格化
已经提供好的inputrc和editrc将把你的很多命令行工具例如mysql和irb转变成vim风格的。并且editrc还包含了一个Ctrl-R反向历史搜索功能这在irb、postgres命令行等等中非常实用。
### Github 问题: [ghi gem](https://github.com/stephencelis/ghi)
我们纳入了`ghi`命令。 试试 `ghi list`然后在使用命令行管理issues中获得快了吧
## Vim - 哪些被包含了呢?
- [导航 - NERDTree, EasyMotion, CtrlP 以及更多](doc/vim/navigation.md)
- [文本对象 - 操作ruby块, 以及更多](doc/vim/textobjects.md)
- [操作代码 - rails支持, 注释, 代码片, 高亮](doc/vim/coding.md)
- [工具 - 缩进, 粘贴缓冲区管理, 以及更多](doc/vim/utils.md)
- [通常的并不添加新命令行的改进](doc/vim/enhancements.md)
下面列出了一些YADR提供的最有用的命令。这不是一个很全的列表。若想挖掘更多信息每天联系其中几个然后开始深入查看上面列表中提供的插件来学习更多。
#### Tmux
- `h`(jkl): 左(下上右)移窗格
- `C-a c`: 创建一个新的窗区
- `C-a s`: 上下分割窗格
- `C-a v`: 左右分割窗格
- `C-a x`: 删除窗格
- `C-a H`(JKL): 左(下上右)移分割线
- `C-a ,`: 输入Tmux命令行模式
- `C-a d`: 退出Session
- `C-a D`: 选择退出Session
- `C-a 1`(23456789): 进入窗区1(23456789)
#### 导航
#### 搜索/代码导航
#### 文件导航
#### 常用编辑命令更好的按键方法
- 自动补全: Ctrl-空格。snipmate代码片段: Tab。
- 将一个单词用这些符号包裹住: `,#` `,"` `,'` `,]` `,)` `,}`。# 是为了 #{ruby字符串插入}。 在Visual模式下也能运行 (谢谢 @cj)。 正常地,他们通过类似`ysw#`这样的来做到。
- 改变包裹标签里的内容: `Cmd-'`, `Cmd-"`, `Cmd-]`, `Cmd-)`, 等等。你不需要在包裹标签里面。(Linux中的`Alt`)
- 进入上一个编辑位置`,.` (和`'.`一样) 因为撇号对于小指来说非常困难。
- `,ci`来改变任何以一个引号对/括符对等等
#### 选项窗口, 窗口, 分割栏
- 使用 `Cmd-1``Cmd-9` 来切换到任何一个特定的选项窗口(就像iTerm和Chrome) - 选项窗口必须被设置为显示号码(Linux中的`Alt`)
- `Ctrl-h,l,j,k` - 来移动到左、右、下、上的分割栏中。这在vim和分割栏一起的时候依然有效感谢`vim-tmux-navigator`。
- `Q` - 只能窗口强杀。用`wincmd c`关闭窗口,如果同一个缓冲区有多个对应窗口, 或者当这是最后一个对应窗口时杀掉缓冲区`bwipeout`。
- `vv` - 垂直分割 (`Ctrl-w,v`)
- `ss` - 水平分割 (`Ctrl-w,s`)
- `,qo` - 打开quickfix窗口 (grep的输出就会到这个窗口里)
- `,qc` - 关闭quickfix
#### Rails & Ruby
- `,vv``,cc` 来在view和controller中切换 - 他们是:Rcontroller和:Rview对应的映射。探索一下:R家族的命令可以了解更多rails.vim的乐趣!
- `,rs``,rl` 来在iTerm中运行rspec 或者一个 spec 行 (查看iTerm窗口来获得信息)
- `,tt` 给spec文件的某个block添加`now: true`tag, 然后可以通过`rspec --tag=now`来测试该block
- `,ss``,sl` 来达到一样的事情,通过使用`spring rspec`一个能将你的Rails specs变得速度更快通过缓存Rails env (必须有spring gem安装过)
#### Vim Dev
- `,vc` - (Vim 命令) 复制光标下的命令然后运行它。对于测试vimrc中单行的改变非常有用。
- `,vr` - (Vim 重新记载) 将当前文件当成vim文件来进行源加载。
#### zsh 功能
- ##### 贴士: $数字 为参数
- `secure_source` -source `~/.yadr/zsh/function.zsh` 文件,让 `function.zsh` 在当前窗口立即工作。
- `pp $1` -使用:`pp xx`, grep 进程的名称。
- `set_proxy` -让终端使用HTTP代理
- `set_vagrant_proxy` -让终端使用vagrant代理
- `set_ss_proxy` -让终端使用socks代理
- `unset_proxy` -取消所用的代理
- `post $1 $2` -使用application/json来curl POST请求
- `git-set-remote $1` -设置项目的git地址
- `gem_source_to_taobao` -将ruby的源地址设置为淘宝镜像
- `docker_rm_all` -删除所有docker镜像
- `Replace $1 $2` -替换当前路径下的所有内容
- `swap $1 $2` -`swap file1 file2`
- `init_db` -初始化Rails项目数据库:
- `kexec` -通过正则表达式pod名称执行k8s pod
- `klog` -通过正则表达式pod名称显示k8s pod日志
- `git_tag_delete` -删除github的tag
- `git_tag_add` -添加github的tag
- `dc` -docker-compose的别名
#### 一些别名定义
- 阅读详情: `~/.yadr/zsh/aliases.zsh`
#### SpaceVim界面元素
SpaceVim的界面元素以[SPC] t或[SPC] T开头可以通过在vim窗口内按下[SPC]键查看二级指令,同理,再按下所需要的二级指令后可以再对三级指令进行查看。
- `SPC t h s` - 显示/隐藏语法高亮
- `SPC t n` - 显示/隐藏行号
- `SPC t h h` - 高亮当前行
- `SPC T m` - 显示/隐藏菜单栏(没看出区别)
- `SPC T t` - 显示/隐藏工具栏(没看出区别)
- `SPC [1-9]` - 跳到指定的窗口
- `SPC f t` - 打开文件树
- `SPC p f` - 在当前文件内查找文件
- `SPC f y` - 在命令行内复制并显示当前文件的绝对路径
- `SPC f S` - 保存全部文件
- `SPC f o` - 在文件树内查找当前文件
- `SPC f D` - 确认删除文件和关联的缓冲区
- `SPC f p` - 在当前项目内查找内容
- `SPC p /` - 在当前项目中模糊搜索文本
- `SPC c l` - 注释或取消注释行
- `SPC c p` - 注释或取消注释段落
#### 切换Tab
当打开多个文件后文件会以Tab的形式罗列在标签栏中可以通过`\[1-9]`切换至对应序号的Tab。
- `\1` - 打开标签1
- `\2` - 打开标签2
- `\3` - 打开标签3
- `\4` - 打开标签4
- `\5` - 打开标签5
- `\6` - 打开标签6
- `\7` - 打开标签7
- `\8` - 打开标签8
- `\9` - 打开标签9
#### 文件树:
文件树用于显示当前打开文件所在位置的文件目录
`SPC f t/<F3>` - 打开文件树
#### 文件树内快捷键:
- `i` - 垂直分割一个新的窗口,并跳转
- `gi` - 垂直分割一个新的窗口,不跳转
- `s` - 水平分割一个新的窗口,并跳转
- `gs` - 水平分割一个新的窗口,不跳转
- `t` - 在新tab中打开一个新的窗口并跳转
- `T` - 在新tab中打开一个新的窗口不跳转
- `o` - 打开当前选中的文件或目录,并跳转
- `go` - 打开当前选中的文件或目录,不跳转
#### vim光标操作
- `k` - 向上移动光标
- `j` - 向下移动光标
- `h` - 向做移动光标
- `l` - 向右移动光标
- `gg` - 页面顶部
- `G` - 页面底部
- `[Ctrl] g` - 显示当前光标位置
- `[Num] G` - 光标移动到指定行
- `0` - 光标移动到行首
- `[Num] w` - 光标移动到指定单词数的开头
- `[Num] e` - 光标移动到指定单词数的末尾
#### vim模式切换
`[Esc]` - 退出当前模式
`i` - 插入模式
`v` - 选择模式
`R` - 替换模式
#### 文档操作:
- `q` - 退出
- `w` - 保存
- `wq` - 保存并退出
- `q!` - 强制退出
#### 文本编辑:
- `y` - 复制选中区域
- `yy` - 复制一整行
- `p` - 粘贴
- `o` - 下方插入一行
- `O` - 上方插入一行
- `A` - 行尾插入
- `a` - 光标右侧插入
- `i` - 光标左侧插入
- `u` - 撤销操作
- `U` - 按行撤销操作
- `[Ctrl] R` - 重做
- `x` - 删除选中的内容
- `dw` - 删除单词
- `d$` - 删除至行尾
- `dd` - 删除整行
- `d[num]w` - 删除指定数量的单词
- `r` - 替换一个字符
- `:s/A/B` - 该行首个A替换成B
- `:s/A/B/g` - 该行所有A替换成B
- `:[num1,num2]s/A/B/g` - 将指定行的A替换成B
- `:%s/A/B/g` - 将指当前tab内的所有A替换成B
文档查询:
- `:/A` - 文档内查找A
- `:/A` - 文档内查找A忽略大小写
- `n` - 下一个
- `N` - 上一个
- `:nohlsearch` - 取消高亮
- `:set hls is` - 高亮显示查询结果
- `:set ic` - 忽略大小写
##
## 扩展或者重载YADR设置
- [调试vim映射](doc/vim/keymaps.md)
- [通过~/.vimrc.after或者类似文件来重载vim设置](doc/vim/override.md)
- [添加你自己的vim插件](doc/vim/manage_plugins.md)
### OSX Hacks
osx文件是一个为开发者或者高能用户进行合理默认设置的bash脚本。在运行它之前先读一下。使用:
```
bin/osx
```
这些特殊技巧是以Lion为中心的。不一定在其他OS上也能行。我最喜欢的模块包括:
- 极快的重复击键速度(现在你可以通过j/k实现快速滚动)
- 无磁盘镜像验证(下载的文件打开速度更快)
- 在finder中显示~/Library文件夹下的内容(在Lion中隐藏的)
### Macvim遇到Lua的麻烦了?
```
brew uninstall macvim
brew remove macvim
brew cleanup
brew install macvim --custom-icons --with-override-system-vim --with-lua --with-luajit
```
### 终端Vim碰到Lua的麻烦
通过RVM管理的Ruby来安装一个终端Vim(和lua一起)会导致neocomplete插件发生segfault。尝试卸载vim然后使用系统ruby来卸载vim:
```
brew uninstall vim
rvm system do brew install vim --with-lua
```
### [Pry](http://pry.github.com/)
Pry提供了一个更好的使用了颜色、tab补全及其他更多小技巧开包即用的IRB。你还可以通过安装[pry-nav](https://github.com/nixme/pry-nav)把它当做一个真正的调试器。
[了解更多YADR's pry定制化以及如何安装](doc/pry.md)
## 语言支持
#### Typescript
fix SpaceVim Unknown function: TSOnBufEnter
* 主要参考
* https://github.com/SpaceVim/SpaceVim/issues/1800
* https://github.com/SpaceVim/SpaceVim/issues/3221
* 解决步骤
* 删除cache rm -rf ~/.cache/vimfiles/.cache
* 打开vim 运行`:CheckHealth` 查看当前vim状态有啥报错修复啥
* 重新打开vim 再运行`:UpdateRemotePlugins`
* 如果还不行,在`~/.local/share/nvim/rplugin.vim` 添加`call dein#reinstall(['nvim-typescript'])`,重新打开vim等待`nvim-typescript`插件安装
#### 问题汇总:
报错:
`npm ERR! Protocol "https:" not supported. Expected "http:"`
解决方案:
淘宝源:`npm config set registry https://registry.npm.taobao.org`
原npm源`npm config set registry http://registry.npmjs.org`
检查node的版本号选择v12.20.1以下的版本请勿使用高版本的node
```
nvm ls
nvm install v12.20.1
nvm use v12.20.1
nvm uninstall 版本号
```
重新安装neovim和typescrip然后重新打开以下vim等待插件安装成功即可
* `npm install -g neovim`
* `npm install -g typescrip`
* 重新打开vim等待nvim-typescript插件安装

525
README.md
View File

@ -1,187 +1,98 @@
# Ruilisi dotfiles # Ruilisi dotfiles
[中文文档 Chinese document](/README.CN.md) ## Get started
### Requirements
## Requirements
* `zsh`, `tmux`, `vim`, `ag` are installed and zsh is set as your login shell: * `zsh`, `tmux`, `vim`, `ag` are installed and zsh is set as your login shell:
```sh ```sh
chsh -s $(which zsh) chsh -s $(which zsh)
``` ```
* `Python 3` and `pynvim` as some layers(`denite`) can't be loaded if they are missing * `Python 3` and `pynvim` as some layers(`denite`) can't be loaded if they are missing
``` ```sh
python3 -m pip install --user --upgrade pynvim python3 -m pip install --user --upgrade pynvim
``` ```
## Install ### Install
```sh ```sh
bash -c "`curl -fsSL https://raw.githubusercontent.com/ruilisi/dotfiles/master/install.sh`" bash -c "`curl -fsSL https://raw.githubusercontent.com/ruilisi/dotfiles/master/install.sh`"
``` ```
Or
## Shortcuts ```sh
bash -c "`curl -fsSL https://git.ruilisi.com/ruilisi/dotfiles/raw/branch/master/install.sh`"
#### Tmux
Prefix is defined as `C-A`(`PRE` for short)
**Scroll Mode**
`PRE [`: Enter Scroll Mode
Shortcut | Function |
:-------:|:--------:|
`S-V` | Select Text |
`Enter` | Copy Text |
`]` | Paste text copied from scroll mode |
#### Vim
* `<L>`: Short for `<localleader>`, which is `\` in our setup
**Defined by Us**
Shortcut | Function
:-------:|:--------:
`C-v` | Enter visual mode
`C-x C-v` | Paste text from system clipboard
`\<L\>tp` |toggle paste
**Defined by Vim**
Shortcut | Function
:-------:|:--------:
`o` |insert a new line below
`O` |insert a new line above
`0` |go to the beginning of the line
`$` |go to the end of the line
`v` |enter character selection mode
`x` |delete selected content
`V` |enter line selection mode
`y` |copy selected content
`p` |paste copied content
`Ctrl+u` |page up
`Ctrl+d` |page down
`:w` |save file
`:q` |quit vim
`w` |move forward one word
`b` |move back one word
`gg` |move to the top of the file
`G` |move to the bottom of the file
`Ctrl+\` |show(hide) the Buffers
`:/ keyword`|search
`n` |go to the next content
`N` |go to the previous content
`[spc] c l`|(un)comment the selected line
`:%s/key1/key2/g`| replae Key1 with Key2
#### Spacevim
Shortcut | Function
:-------:|:--------:
SPC f v d| open configuration file
#### vim && markdown
* Install `prettier`: `yarn global add prettier` or `npm install --global prettier`
* Open vim and enter command: `:SPUPdate`
## Q&A
#### How to edit command line in vim
During editing command line, press `esc` to enter normal mode, then press `C-x C-e` to edit current command line in vim.
#### install iTerm Solarized Colors
YADR will install the Solarized color scheme into iTerm. You can choose Solarized Dark in Profiles => Colors => Load Presets.
#### swap the positions of caps-lock and escape by [Karabiner-Elements](https://pqrs.org/osx/karabiner/index.html).
Escape is the most commonly used key in vim. The old keyboard used to have the Escape as big as `tab`, the worst part of the Apple keyboard is that the `ESC` key is too small. Howeverwe can swap the roles of `ESC` key and `Caps` key to solve these problems. If you keep tapping on the small target in the corners, you woll definitely reduce your efficiency drastically, and maybe you will cause small inijuries to your hands to repeated muscle force.
#### Set a system-level hotkey for iTerm (Keys=>Hotkey)
We recommend using `Cmd-Escape`, which is actually `Cmd-Capslock`(because the roles are interchanged).
#### Select "Use Lion-style full screen" in the General of iTerm.
After this setting, you will get a large screen that can be switched without having to go through the switching space.
#### Cancel Prefer native fullscreen in the Advanced Settings of MacVim.
Lion-style space switching will reduce all efficiency for no reason, just like iTerm.
## If you want to run on the terminal
- Make sure that your terminal has installed the Solarized color scheme!
- If you don't want to use a terminal with solarized color matching, then makr sure you did this: `let g:yadr_using_unsolarized_terminal = 1 `
# in ~/.vimrc.before
- if you want to use an alternavtive color scheme, such as Gruvbox, then do this in your `~/.vimrc.after`:
``` ```
let g:yadr_disable_solarized_enhancements = 1
colorscheme base16-twilight
```
### Upgrade ### Upgrade
```sh
Upgrade is very simple.
```bash
cd ~/.yadr cd ~/.yadr
git pull --rebase git pull --rebase
rake update rake update
``` ```
## ZSH
## What has been included and how do I configure it?
Keep reading to learn more about what YADR has to offer you!
### [Homebrew](http://mxcl.github.com/homebrew/)
Homebrew is a missing OSX package management system, and it will be installed automatically.
We automatically installed some commonly used packages, such as ctags, git, macvim, hub, and RipGrep (rg). Note that our auto-completion plugin requires MacVim to support Lua. The installer knows how to install it, but if you have installed it before, you need to manually delete your previous MacVim.
### ZSH
Think of Zsh as a more awesome Bash, but without much learning costs. It will do automatic spelling correction, grammar highlighting, and more for the command line you write. We have also added many enhancements:
- Vim mode and bash style historical anti-query: `Ctrl-R`
- Insert the result of the previous command: `Ctrl-x,Ctrl-l`
- Fuzzy match-if you type the wrong folder name, tab completion will correct it.
- [fasd](https://github.com/clvv/fasd) ubtegration - Entering `z` will help you semi-automatically match the recently used folders. Tab completion is also tuen on.
- [Prezto - the zsh behind YADR's](http://github.com/sorin-ionescu/prezto) - [Prezto - the zsh behind YADR's](http://github.com/sorin-ionescu/prezto)
- [How to add your own ZSH theme](doc/zsh/themes.md) - [How to add your own ZSH theme](doc/zsh/themes.md)
### Shortcuts
Shortcut | Alias
:-----------|:--------
Ctrl-R | Vim mode and bash style historical anti-query
ae | Edit alias
ar | Reload alias
ESC C-x C-e |Edit current command line in vim
### Commands
> $1, $2 represent arguments
- `secure_source` -source `~/.yadr/zsh/function.zsh` file, let `function.zsh` modify work immediately in current window
- `pp $1` -useage:`pp xx`, grep process by name
- `set_proxy` -set terminal proxy use http proxy
- `set_vagrant_proxy` -set terminal proxy use vagrant http proxy
- `set_ss_proxy` -set terminal proxy use socks proxy
- `unset_proxy` -cancel all proxy
- `post $1 $2` -curl POST with application/json
- `git-set-remote $1` -set project git remote url
- `gem_source_to_taobao` -set ruby gem source to taobao
- `docker_rm_all` -delete all docker images
- `Replace $1 $2` -replcae all text under current path
- `swap $1 $2` -`swap file1 file2`
- `init_db` -init rails project database
- `kexec` -execute k8s pod by regex pod name
- `klog` -show k8s pod log by regex pod name
- `git_tag_delete` -delete gtihub tag
- `git_tag_add` -add gtihub tag
- `dc` -alias of docker-compose
### Alias ### [fasd](https://github.com/clvv/fasd)
The name fasd comes from the default suggested aliases f(files), a(files/directories), s(show/search/select), d(directories).
Most of the things we use every day can be done with two to three character aliases. Please modify them yourself:
Some situations where you can type in the command on the left and fasd will "expand" your command into the right side.
``` ```
ae # alias edit v def conf => vim /some/awkward/path/to/type/default.conf
ar # alias reload j abc => cd /hell/of/a/awkward/path/to/get/to/abcdef
m movie => mplayer /whatever/whatever/whatever/awesome_movie.mp4
o eng paper => xdg-open /you/dont/remember/where/english_paper.pdf
vim `f rc lo` => vim /etc/rc.local
vim `f rc conf` => vim /etc/rc.conf
``` ```
Fasd comes with some useful aliases by default:
```sh
alias a='fasd -a' # any
alias s='fasd -si' # show / search / select
alias d='fasd -d' # directory
alias f='fasd -f' # file
alias sd='fasd -sid' # interactive directory selection
alias sf='fasd -sif' # interactive file selection
alias z='fasd_cd -d' # cd, same functionality as j in autojump
alias zz='fasd_cd -d -i' # cd with interactive selection
```
Fasd will smartly detect when to display a list of files or just the best
match. For instance, when you call fasd in a subshell with some search
parameters, fasd will only return the best match. This enables you to do:
```sh
mv update.html `d www`
cp `f mov` .
```
### Git customization: ### Git customization:
@ -190,7 +101,7 @@ YADR will take over your ~/.gitconfig, so if you want to store your git username
We recommend setting your user information in this file. In addition, you can set your environment variables appropriately in your ~/.secrets. We recommend setting your user information in this file. In addition, you can set your environment variables appropriately in your ~/.secrets.
Shortcut | Alias Shortcut | Alias
:-------:|:--------: :--------|:--------
`ga` |`git add` `ga` |`git add`
`gb` |`git branch` `gb` |`git branch`
`gbc` or `gnb` |`git checkout -b` `gbc` or `gnb` |`git checkout -b`
@ -214,98 +125,65 @@ Shortcut | Alias
`gsp` |`git stash pop` `gsp` |`git stash pop`
`gst` |`git stash` `gst` |`git stash`
## Tmux
### Settings
##### vim-gitgutter
- `]h` next hunk(change point)
- `[h` previous hunk
- `<Leader>ha` Put the hunk into the state area to save
- `<Leader>hr` Revoke the hunk
### RubyGems
.gemrc is included. No need to enter `gem install whatever --no-ri --no-rdoc`. `--no-ri --no-rdoc` anymore, because it's all done by default.
### Settings of Tmux
`tmux.conf` provides some reasonable default settings for tmux on Mac OS, such as a powerful status bar and VIM keyboard bindings. You can modify the configuration in `~/.tmux.conf.user`. `tmux.conf` provides some reasonable default settings for tmux on Mac OS, such as a powerful status bar and VIM keyboard bindings. You can modify the configuration in `~/.tmux.conf.user`.
### Shortcuts
Prefix is defined as `C-a`(`PRE` for short)
Shortcut | Function
:---------|:--------
C-h(jkl) |←(↓↑→)Move pane
PRE c |Craete a new pane
PRE s |Split panes up and down
PRE v |Split panes left and right
PRE x |Kill pane
PRE h(jkl)|←(↓↑→)Move dividing line
PRE , |Switch to Tmux command line mode
PRE d |Exit Session
PRE D |Exit Session
PRE 1 |Enter pane 1
> `C` is short for `Ctrl`
Press `PRE [` to enter Scroll Mode
Shortcut | Function |
:--------|:---------|
`Shift-V`| Select Text|
`Enter` | Copy Text |
`]` | Paste text copied from scroll mode |
### Make everything Vim stylized ## Vim & Spacevim
* `<L>`: Short for `<localleader>`, which is `\` in our setup
The provided inputrc and editrc will transform many of your command-line tools-such as mysql and irb-into vim style. And editrc also contains a Ctrl-R reverse history search function, which is very useful in irb, postgres command line, etc. **Defined by Us**
### Vim Basic
Refer [here](doc/vim-basic.md)
### Github problems: [ghi gem](https://github.com/stephencelis/ghi) ### General Shortcuts
We included the `ghi` command. Try `ghi list`, and have fun in managing issues using the command line!
## Vim - Which ones are included?
- [navigation - NERDTree, EasyMotion, CtrlP and more](doc/vim/navigation.md)
- [text object - Manipulate Ruby blocks, and more](doc/vim/textobjects.md)
- [modify the code - support of rails, commit, code block, highlight](doc/vim/coding.md)
- [tools - Indentation, paste buffer management, and more](doc/vim/utils.md)
- [usually do not add new command line improvements](doc/vim/enhancements.md)
Some of the most useful commands provided by YADR are listed below. This is not a comprehensive list. If you want to dig out more information, contact a few of them every day, and then start to look at the plugins provided in the above list to learn more.
#### Tmux
C refer to Ctrl
Shortcut | Function Shortcut | Function
:-------:|:--------: :-------:|:--------:
`h(jkl)` |`←(↓↑→)Move pane` C-v | Enter visual mode
`C-a c` |`Craete a new pane` C-x C-v | Paste text from system clipboard
`C-a s` |`Split panes up and down` <L>tp | Toggle paste
`C-a v` |`Split panes left and right` SPC f v d| Open configuration file
`C-a x` |`Kill pane` SPC g . | Enter version control transient-state
`C-a H(JKL)` |`←(↓↑→)Move dividing line` SPC l p | Preview markdown
`C-a ,` |`Switch to Tmux command line mode`
`C-a d` |`Exit Session`
`C-a D` |`Exit Session`
`C-a 1` |`Enter pane 1`
#### Index ### markdown
* Install `prettier`: `yarn global add prettier` or `npm install --global prettier`
* Open vim and enter command: `:SPUPdate`
#### Code search ### Option window, window, split bar
#### File index
#### A better way to press keys for common editing commands
- Autocomplete: Ctrl-[SPC]. snipmate code block: Tab。
- Wrap a word with these symbols: `,#` `,"` `,'` `,]` `,)` `,}`。# Is for #{ruby string insertion}. It can also run in Visual mode (thanks @cj). Normally, they do it through something like `ysw#`.
- Change the content of the tag: `Cmd-'`, `Cmd-"`, `Cmd-]`, `Cmd-)` ... You dont need to be in the tag。(`Alt` in Linux)
- Go to the previous editing position`,.` (just like `'.`) Because `'` is very difficult for the little finger.
- `,ci`To change anything with a pair of quotes/parentheses, etc.
#### Option window, window, split bar
- Use `Cmd-1` to `Cmd-9` to switch to any specific option window(like iTerm and Chrome) - the option window must be set to the display number(`Alt` in Linux)
- `Ctrl-h,l,j,k` - use to move to left、right、top、bottom commpartment. This is still valid when vim and the split bar are together, thanks to `vim-tmux-navigator` - `Ctrl-h,l,j,k` - use to move to left、right、top、bottom commpartment. This is still valid when vim and the split bar are together, thanks to `vim-tmux-navigator`
- `Q` - Only force kill the window.Close window by `wincmd c`, if the same buffer has multiple corresponding windows, or kill the buffer when this is the last corresponding window`bwipeout`。 - `Q` - Enter Ex mode
- `vv` - Vertical separation (`Ctrl-w,v`) - `vv` - Vertical separation (`Ctrl-w,v`)
- `ss` - Horizontal separation (`Ctrl-w,s`) - `ss` - Horizontal separation (`Ctrl-w,s`)
- `,qo` - Open quickfix window (The output of grep will go to this window) - `,qo` - Open quickfix window (The output of grep will go to this window)
- `,qc` - close quickfix - `,qc` - close quickfix
#### Rails & Ruby #### Rails & Ruby
@ -316,45 +194,9 @@ Shortcut | Function
#### Vim Dev #### Vim Dev
- `,vc` - (Vim command) Copy the command under the cursor and run it. Very useful for testing single-line changes in vimrc. - `,vc` - (Vim command) Copy the command under the cursor and run it. Very useful for testing single-line changes in vimrc.
- `,vr` - (Vim re-documented) Use the current file as a vim file to load the source. - `,vr` - (Vim re-documented) Use the current file as a vim file to load the source.
#### zsh function
- ##### tips: $number is the argument
- `secure_source` -source `~/.yadr/zsh/function.zsh` file, let `function.zsh` modify work immediately in current window
- `pp $1` -useage:`pp xx`, grep process by name
- `set_proxy` -set terminal proxy use http proxy
- `set_vagrant_proxy` -set terminal proxy use vagrant http proxy
- `set_ss_proxy` -set terminal proxy use socks proxy
- `unset_proxy` -cancel all proxy
- `post $1 $2` -curl POST with application/json
- `git-set-remote $1` -set project git remote url
- `gem_source_to_taobao` -set ruby gem source to taobao
- `docker_rm_all` -delete all docker images
- `Replace $1 $2` -replcae all text under current path
- `swap $1 $2` -`swap file1 file2`
- `init_db` -init rails project database
- `kexec` -execute k8s pod by regex pod name
- `klog` -show k8s pod log by regex pod name
- `git_tag_delete` -delete gtihub tag
- `git_tag_add` -add gtihub tag
- `dc` -alias of docker-compose
#### some alias define
- you can find detail in `~/.yadr/zsh/aliases.zsh`
#### SpaceVim Interface elements: #### SpaceVim Interface elements:
The interface elements of SpaceVim start with [SPC] t or [SPC] T. You can view the second-level instructions by pressing the [SPC] key in the vim window. In the same way, press the required second-level instructions and then you can check the three Level instructions to view. The interface elements of SpaceVim start with [SPC] t or [SPC] T. You can view the second-level instructions by pressing the [SPC] key in the vim window. In the same way, press the required second-level instructions and then you can check the three Level instructions to view.
@ -390,159 +232,26 @@ When multiple files are opened, the files will be listed in the tab bar in the f
#### File tree:
The file tree is used to display the file directory where the currently opened file is located. `SPC f t/<F3>`-Open the file tree
#### Shortcut keys in the file tree: ## iTerm
- `i` - Split a new window vertically and jump ### iTerm Solarized Colors
- `gi` - Split a new window vertically without jumping
- `s` - Split a new window horizontally and jump YADR will install the Solarized color scheme into iTerm. You can choose Solarized Dark in Profiles => Colors => Load Presets.
- `gs` - Split a new window horizontally without jumping
- `t` - Open a new window in a new tab and jump
- `T` - Open a new window in a new tab without jumping
- `o` - Open the currently selected file or directory and jump
- `go` - Open the currently selected file or directory without jumping
## [Homebrew](http://mxcl.github.com/homebrew/)
#### vim cursor operation:
- `k` - Move cursor up
- `j` - Move cursor down
- `h` - Move cursor left
- `l` - Move cursor right
- `gg` - Move to top of the file
- `G` - Move to bottom of the file
- `[Ctrl] g` - Show current cursor position
- `[Num] G` - Cursor to the specified line
- `0` - Cursor to the beginning of the line
- `[Num] w` - Move the cursor to the beginning of the specified number of words
- `[Num] e` - Move the cursor to the end of the specified number of words
Homebrew is a missing OSX package management system, and it will be installed automatically.
#### vim mode switch: We automatically installed some commonly used packages, such as ctags, git, macvim, hub, and RipGrep (rg). Note that our auto-completion plugin requires MacVim to support Lua. The installer knows how to install it, but if you have installed it before, you need to manually delete your previous MacVim.
`[Esc]` - Exit current mode
`i` - Insert mode
`v` - Select mode
`R` - Replace mode
#### Document operation:
- `q` - quit
- `w` - save
- `wq` - save & quit
- `q!` - foce quit
#### Document editing:
- `y` - Copy selected area
- `yy` - Copy entire line
- `p` - Paste
- `o` - Insert a row below
- `O` - Insert a row above
- `A` - End of line insertion
- `a` - Insert to the right of the cursor
- `i` - Insert to the left of the cursor
- `u` - Undo operation
- `U` - Undo operation by line
- `[Ctrl] R` - Redo
- `x` - Delete selected area
- `dw` - Delete word
- `d$` - Delete to end of line
- `dd` - Delete entire line
- `d[num]w` - Delete the specified number of words
- `r` - Replace a character
- `:s/A/B` - Replace the first A in the line with B
- `:s/A/B/g` - Replace all A in this line with B
- `:[num1,num2]s/A/B/g` - Replace A in the specified line with B
- `:%s/A/B/g` - Replace all A in the current tab with B
#### Document query:
- `:/A` - Find A in the document
- `:/A` - Find A in the document, ignoring case
- `n` - To the next
- `N` - To the previous
- `:nohlsearch` - Cancel highlight
- `:set hls is` - Highlight query results
- `:set ic` - Ignore case
##
## Extend or reload YADR settings
- [Debug vim mapping](doc/vim/keymaps.md)
- [Reload vim settings through ~/.vimrc.after or similar files](doc/vim/override.md)
- [Add your own vim plugin](doc/vim/manage_plugins.md)
## Miscellaneous
- [Special praise and thanks](doc/credits.md)
- [Other recommended tools to improve OSX productivity](doc/osx_tools.md)
- [Yan's Blog](http://yanpritzker.com)
### OSX Hacks
The osx file is a bash script with reasonable default settings for developers or high-power users. Read it before running it. use:
```
bin/osx
```
These special skills are centered on Lion. Not necessarily on other OSs. My favorite modules include:
- Extremely fast repeated keystroke speed (now you can achieve fast scrolling through j/k)
- No disk mirror verification (downloaded files open faster)
- Display the contents of the ~/Library folder in the finder (hidden in Lion)
### Macvim has trouble with Lua?
```
brew uninstall macvim
brew remove macvim
brew cleanup
brew install macvim --custom-icons --with-override-system-vim --with-lua --with-luajit
```
### Terminal Vim has trouble with Lua?
Installing a terminal Vim (together with lua) through Ruby managed by RVM will cause a segfault on the neocomplete plugin. Try to uninstall vim, and then use system ruby to uninstall vim:
```
brew uninstall vim
rvm system do brew install vim --with-lua
```
### [Pry](http://pry.github.com/)
Pry provides a better IRB that uses colors, tab completion, and other more tricks out of the box. You can also install [pry-nav](https://github.com/nixme/pry-nav) as a real debugger.
[Learn more about YADR's pry customization and how to install](doc/pry.md)
## Language support ## Language support
#### Typescript #### Typescript
fix SpaceVim Unknown function: TSOnBufEnter fix `SpaceVim Unknown function: TSOnBufEnter`
* References * References
* https://github.com/SpaceVim/SpaceVim/issues/1800 * https://github.com/SpaceVim/SpaceVim/issues/1800
* https://github.com/SpaceVim/SpaceVim/issues/3221 * https://github.com/SpaceVim/SpaceVim/issues/3221
@ -551,3 +260,7 @@ fix SpaceVim Unknown function: TSOnBufEnter
* Open vim run `:CheckHealth` check the current vim status, and fix any errors. * Open vim run `:CheckHealth` check the current vim status, and fix any errors.
* Reopen vim and run `:UpdateRemotePlugins` * Reopen vim and run `:UpdateRemotePlugins`
* If it still doesn't work, add `call dein#reinstall(['nvim-typescript'])` to `~/.local/share/nvim/rplugin.vim`, reopen vim and wait for the `nvim-typescript` plugin to install * If it still doesn't work, add `call dein#reinstall(['nvim-typescript'])` to `~/.local/share/nvim/rplugin.vim`, reopen vim and wait for the `nvim-typescript` plugin to install
## Troubleshoot
Refer more at https://github.com/skwp/dotfiles

55
doc/vim-basic.md Normal file
View File

@ -0,0 +1,55 @@
# Vim Basic
## Shortcuts
Shortcut |Function
:--------|:--------
h[ljk] | Move cursor left/right/down/up
o | Insert a new line below
O | Insert a new line above
a | Insert to the right of the cursor
A | Insert at the end of line
i | Insert to the left of the cursor
I | Insert at the beginning of current line
u | Undo operation
U | Undo operation by line
CTRL r | Redo
x | Delete selected content
dw | Delete word
d$ | Delete to end of line
dd | Delete entire line
d[num]w | Delete the specified number of words
r | Replace a character
R | Enter replacement mode
0 | Go to the beginning of the line
$ | Go to the end of the line
v | Enter character selection mode
V | Enter line selection mode
y | Copy selected content
yy | Copy entire line
p | Paste copied content
Ctrl+u | Page up
Ctrl+d | Page down
:w | Save file
:q | Quit vim
w | Move forward one word
b | Move back one word
gg | Move to the top of the file
G | Move to the bottom of the file
Ctrl+\ | Show(hide) the Buffers
/ keyword| Search
n | Go to the next content
N | Go to the previous content
SPC c l | (Un)comment the selected line
gg | Move to the top
G | Move to the bottom
CTRL g | Show current cursor position
[NUM] G | Cursor to the specified line
0 | Cursor to the beginning of the line
[NUM] w | Move the cursor to the beginning of the specified number of words
[NUM] e | Move the cursor to the end of the specified number of words
:[%]s/A/B[/g]| Replae Key1 with Key2(`%`: Selected area, `g`: for all occurrences in every line)
:q | Quit
:w | Save
:wq | Save & quit
:q! | Foce quit
ESC | Exit current mode