Skip to content

Latest commit

 

History

History
34 lines (26 loc) · 839 Bytes

cheat_codes.adoc

File metadata and controls

34 lines (26 loc) · 839 Bytes

Read in lines 147-227 of foo.c:

:r! sed -n 147,227p /path/to/foo/foo.c

Replace until the next occurance of x:

ctx

Quote a word, using single quotes:

ciw'Ctrl+r"'
  • ciw - Delete the word the cursor is on, and end up in insert mode.

  • ' - add the first quote.

  • Ctrl+r" - Insert the contents of the " register, aka the last yank/delete.

  • ' - add the closing quote.

Rename a file w/o leaving vim

function! RenameFile()
    let old_name = expand('%')
    let new_name = input('New file name: ', expand('%'), 'file')
    if new_name != '' && new_name != old_name
        exec ':saveas ' . new_name
        exec ':silent !rm ' . old_name
        redraw!
    endif
endfunction
map <leader>r :call RenameFile()<cr>