Wednesday, October 17, 2018

I'm a big fan of fzf, because of that I used more vim now

to integrate with vim, simply copy autoload and plugin folder to your ~/.vim/, and add these lines to ~/.vimrc:

set rtp+=~/.fzf
let g:fzf_action = {
  \ 'ctrl-t': 'tab split',
  \ 'ctrl-x': 'split',
  \ 'ctrl-v': 'vsplit' }
imap <c-x><c-k> <plug>(fzf-complete-word)
imap <c-x><c-f> <plug>(fzf-complete-path)
imap <c-x><c-j> <plug>(fzf-complete-file-ag)
imap <c-x><c-l> <plug>(fzf-complete-line)

I also added a shortcut for :Files:

nnoremap <leader>f :Files<CR>

once you selected, can split by ctrl-t/ctrl-x/ctrl-v as configured above

and under insert mode, c-x c-l to open complete line function, really useful this one

Thursday, October 18, 2018

a command to run command when files change: entr

Monday, October 22, 2018

to remove os x Are you sure you want to open it? message when opening an application:

$ sudo xattr -r -d com.apple.quarantine /Applications/Slack.app /Applications/Firefox.app

Friday, October 26, 2018

vim

moving buffers:

  • ctrl-w T: move buffer to new tab
  • ctrl-w v / ctrl-w S: split buffer vertically / horizontally
  • ctrl-w t ctrl-w K: change vertically split to horizontally
  • ctrl-w t ctrl-w H: change horizontally split to vertically
  • ctrl-^: switch between current / previous buffers

and about register:

  • "[reg][command] to use register [reg], for example "ayy copies line to register a, and "ap paste with register a
  • default register is "
  • :reg: view register list
  • under insert mode, ctrl-r " to paste default register

specify location to store .swp files (prevent watch file tools refresh frequently), add these to .vimrc:

set dir=$HOME/.vim/tmp/swap
if !isdirectory(&dir) | call mkdir(&dir, 'p', 0700) | endif


to add a custom fzf completion is quite easy, following the instructions on fzf completion examples)

for example, I want auto complete docker container names:

_fzf_complete_docker() {
    _fzf_complete "" "$@" < <(
            sudo docker ps -a | awk 'NR>1'
            )
}

_fzf_complete_docker_post() {
    awk '{print $NF}'
}

then run this: [ -n "$BASH" ] && complete -F _fzf_complete_docker docker


Blog Archives

Search Blog: