Neovim command line commands
Related to: notes / Neovim (LazyVim) key commands.
NOTE: I’m not including the : character in the commands. Enter : to open the command-line prompt.
Copy current filename to the system clipboard
let @+ = expand('%:t')
Explanation:
let @+ =: assigns the results of the following expression to the+register.+is a special register that is linked to the system’s clipboard.expand('%:t): expands the special%variable (it represents the current buffer’s full path). Thetmodifier extracts the filename (excludes the path).
Related commands
Copy the current root filename (excluding extension) to the clipboard
let @+ = expand('%:t:r')
The r (root) modifier removes the extension.
Copy the full absolute path to the clipboard
let @+ = expand('%:p')
Copy the relative path to the clipboard
let @+ = expand('%:')
Tags: