diff options
| -rw-r--r-- | alias | 11 | ||||
| -rw-r--r-- | vim/init/keymaps.vim | 22 | ||||
| -rw-r--r-- | vim/lua/mappings.lua | 1 |
3 files changed, 25 insertions, 9 deletions
| @@ -54,17 +54,12 @@ fi | |||
| 54 | alias vu='vim -u NONE' | 54 | alias vu='vim -u NONE' |
| 55 | alias vr='vim -R' | 55 | alias vr='vim -R' |
| 56 | # Edit last file | 56 | # Edit last file |
| 57 | alias vl="vim -c 'norm '" | 57 | alias vl="vim -c 'norm '" |
| 58 | # Use Telescope to select recent files | 58 | # Use Telescope to select recent files |
| 59 | vll() { | 59 | vll() { nvim -c 'Telescope oldfiles'; } |
| 60 | nvim -c 'Telescope oldfiles' | ||
| 61 | } | ||
| 62 | # Apply defaut session | 60 | # Apply defaut session |
| 63 | alias vS="vim -S /tmp/vim.session" | 61 | alias vS="vim -S /tmp/vim.session" |
| 64 | #alias vl="vim $(sed -n '/^[^#]/{p;q}' ~/.vim_mru_files)" | 62 | alias cdv='cd ~/.config/nvim' |
| 65 | alias ve="vim ~/helper/vim/init.vim" | ||
| 66 | alias vq='vim ~/buffer' | ||
| 67 | alias cdv='cd ~/.vim/vim-init' | ||
| 68 | vs() { which $1 && vim $(which $1); } | 63 | vs() { which $1 && vim $(which $1); } |
| 69 | [ "$shell" = zsh ] && compdef vs=which | 64 | [ "$shell" = zsh ] && compdef vs=which |
| 70 | alias vim.dos2unix="vim '+set ff=unix' '+x'" | 65 | alias vim.dos2unix="vim '+set ff=unix' '+x'" |
diff --git a/vim/init/keymaps.vim b/vim/init/keymaps.vim index 3c3ebc8..68103a1 100644 --- a/vim/init/keymaps.vim +++ b/vim/init/keymaps.vim | |||
| @@ -11,6 +11,7 @@ | |||
| 11 | " - MANAGE_BUFFERS | 11 | " - MANAGE_BUFFERS |
| 12 | " - SURROURD_WITH_CHAR | 12 | " - SURROURD_WITH_CHAR |
| 13 | " - REDIRECTION_WITH_BUFFER | 13 | " - REDIRECTION_WITH_BUFFER |
| 14 | " - QUICK_SUBSTITUTE | ||
| 14 | " - 终端支持 | 15 | " - 终端支持 |
| 15 | " - 编译运行 | 16 | " - 编译运行 |
| 16 | " - 符号搜索 | 17 | " - 符号搜索 |
| @@ -262,6 +263,7 @@ noremap <leader><leader>fm :set foldmethod= | |||
| 262 | let g:lastbuffer = 1 | 263 | let g:lastbuffer = 1 |
| 263 | au BufLeave * let g:lastbuffer = bufnr() | 264 | au BufLeave * let g:lastbuffer = bufnr() |
| 264 | 265 | ||
| 266 | |||
| 265 | "---------------------------------------------------------------------- | 267 | "---------------------------------------------------------------------- |
| 266 | " SURROURD_WITH_CHAR | 268 | " SURROURD_WITH_CHAR |
| 267 | "---------------------------------------------------------------------- | 269 | "---------------------------------------------------------------------- |
| @@ -305,6 +307,26 @@ endfunction | |||
| 305 | command! -nargs=1 -complete=command Redir silent call Redir(<q-args>) | 307 | command! -nargs=1 -complete=command Redir silent call Redir(<q-args>) |
| 306 | nnoremap <leader>rr :Redir | 308 | nnoremap <leader>rr :Redir |
| 307 | 309 | ||
| 310 | |||
| 311 | "---------------------------------------------------------------------- | ||
| 312 | " QUICK_SUBSTITUTE | ||
| 313 | "---------------------------------------------------------------------- | ||
| 314 | function! IsSubstituteTextSelected() | ||
| 315 | execute "norm \<ESC>" | ||
| 316 | " Get position of the first/last char | ||
| 317 | echo col("'<") col("'>") len(getline('.'))+1 | ||
| 318 | return col("'<") != 1 || col("'>") != len(getline('.')) + 1 | ||
| 319 | endfunction | ||
| 320 | function! SelectAreaOrDoSubstitute() | ||
| 321 | if IsSubstituteTextSelected() | ||
| 322 | call feedkeys('gv"aygv*NVL') | ||
| 323 | else | ||
| 324 | call feedkeys("gv:s//\<C-R>a/g\<Left>\<Left>") | ||
| 325 | endif | ||
| 326 | endfunction | ||
| 327 | vnoremap <CR> <Cmd>call SelectAreaOrDoSubstitute()<CR> | ||
| 328 | |||
| 329 | |||
| 308 | "---------------------------------------------------------------------- | 330 | "---------------------------------------------------------------------- |
| 309 | " Markdown items (temproray solution) | 331 | " Markdown items (temproray solution) |
| 310 | "---------------------------------------------------------------------- | 332 | "---------------------------------------------------------------------- |
diff --git a/vim/lua/mappings.lua b/vim/lua/mappings.lua index 3451ddf..d3cfda0 100644 --- a/vim/lua/mappings.lua +++ b/vim/lua/mappings.lua | |||
| @@ -25,7 +25,6 @@ vim.keymap.set("n", "<leader>ds", vim.diagnostic.setloclist, { desc = "lsp diagn | |||
| 25 | 25 | ||
| 26 | -- nvimtree | 26 | -- nvimtree |
| 27 | vim.keymap.set("n", "<C-n>", "<cmd>NvimTreeToggle<CR>", { desc = "nvimtree toggle window" }) | 27 | vim.keymap.set("n", "<C-n>", "<cmd>NvimTreeToggle<CR>", { desc = "nvimtree toggle window" }) |
| 28 | vim.keymap.set("n", "<leader>nf", "<cmd>NvimTreeFocus<CR>", { desc = "nvimtree focus window" }) | ||
| 29 | 28 | ||
| 30 | -- telescope | 29 | -- telescope |
| 31 | vim.keymap.set("n", "<leader>f", "<cmd>Telescope oldfiles<CR>", { desc = "telescope find oldfiles" }) | 30 | vim.keymap.set("n", "<leader>f", "<cmd>Telescope oldfiles<CR>", { desc = "telescope find oldfiles" }) |