Viml input/output

From wikinotes
Revision as of 00:04, 24 December 2021 by Will (talk | contribs) (→‎Filesystem)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

print

echo "text"   "print text/variable
echom "text"  "print text/variable (and log message to :messages)

You can see the history of printed output (at least echom output) using :messages

There are other variations on echo, see help echo.

Filesystem

call delete('/absolute/path/to/file')           " Delete Files
call filereadable('/absolute/path/to/file')     " Check if File exists/is readable
call executable('netstat')                      " Check if executable exists/is on PATH
call globpath( '.', '*' )                       " list files
call expand('<sfile>:p:h')                      " abspath to dir containing current script (in module, not func)
call fnamemodify('abc.txt', ':p')               " abspath from string
call expand('%:p')                              " abspath from buffer
call isdirectory('/var/tmp')
call mkdir('/var/tmp', 'p')

expand variables

%              current file name
#              alternate file name
#n             alternate file name n
<cfile>        file name under the cursor
<afile>        autocmd file name
<abuf>         autocmd buffer number (as a String!)
<amatch>       autocmd matched name
<sfile>        sourced script file or function name
<slnum>        sourced script file line number
<cword>        word under the cursor
<cWORD>        WORD under the cursor
<client>       the {clientid} of the last received
        message |server2client()|

expand/fnamemodify modifiers

:p        expand to full path
:h        head (filename only)
:t        tail (path to parent)
:r        root (remove one extension)
:e        extension only