re: What's your favorite Vim trick? VIEW POST

FULL DISCUSSION
 

I have many tricks on at my "init.vim"

"Make search faster
:nnoremap <space> /

"Alternate "nonumber | number | relativenumber"
:nnoremap <C-n> :let [&nu, &rnu] = [!&rnu, &nu+&rnu==1]<cr>

" allows me to use a smarter cgn
nnoremap c* *<c-o>cgn
nnoremap c# #<C-o>cgn

" allows to type gf to "go to file"
set path+=.,**

I also like "Ctrl-6" to jump to alternate buffer ":%y+" to copy the entire buffer to the clipboard. "gx" to open links. "gv" to reselect. "gi" to start insert at the last inserting point.

" Use whole "words" when opening URLs.
" This avoids cutting off parameters (after '?') and anchors (after '#'). 
" See http://vi.stackexchange.com/q/2801/1631
let g:netrw_gx="<cWORD>"    

" copy the last command to clipboard
:let @+=@:

" avoid clipboard hacking security issue
" http://thejh.net/misc/website-terminal-copy-paste
inoremap <C-R>+ <C-R><C-R>+

On my ~/.zshrc and ~/.bashrc I have

" lvim opens the last edited file on vim
alias lvim='vim -c "normal '\''0"'

# Edit clipboard on a vim scratch buffer
alias vimscratch="vim -c 'setlocal buftype=nofile bufhidden=wipe nobuflisted noswapfile'"
alias pbpaste='xclip -i -selection clipboard -o'
alias pbcopy='xclip -selection clipboard'
alias vcb="pbpaste | vimscratch -"


# Open files very quicly using fzy
alias nfu='nvim $(find ~/.dotfiles -type f | fzy)'
code of conduct - report abuse