Skip to content

vim-utilities/date-time

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Date Time

Commands for injecting date and/or time into current buffer

Byte size of Date Time Open Issues Open Pull Requests Latest commits License



Requirements

This repository requires the [Vim][vim_home] text editor to be installed the source code is available on GitHub -- vim/vim, and most GNU Linux package managers are able to install Vim directly, eg...

  • Arch based Operating Systems
sudo packman -Syy

sudo packman -S vim
  • Debian derived Distributions
sudo apt-get update

sudo apt-get install vim

Quick Start

This repository is a Vim plugin and can be installed via a number of methods.

  1. Source

    mkdir -p ~/git/hub/vim-utilities
    
    cd ~/git/hub/vim-utilities/date-time
    
    git clone [email protected]:vim-utilities/date-time.git
    
    make install
  2. Plug

    ~/.vimrc (snip)

    call plug#begin('~/.vim/plugged')
      " ...
      Plug 'vim-utilities/date-time'
      " ...
    call plug#end()

    After adding above Plug line to your Vim configuration file, run the following PlugInstall Ex mode command within a Vim session

    :PlugInstall date-time
  3. Vundle

    ~/.vimrc (snip)

    call vundle#begin('~/.vim/plugged')
      " ...
      Plugin 'vim-utilities/date-time'
      " ...
    call vundle#end()

    After adding above Plugin line to your Vim configuration file, run the following PluginInstall Ex mode command within a Vim session

    :PluginInstall

Usage

After installation use help to review configuration, and usage, details, eg.

:help date-time.txt

" Jump to specific sections
:help date-time-ex-commands
:help date-time-normal-map
:help date-time-visual-map
:help date-time-configuration
:help date-time-notes

Alternatively plugin documentation maybe reviewed within doc/date-time.txt file.


Replace selection example

By default the <Leader>R sequence in Visual select mode will Replace any date/time format strings.

Consider the following template time-sheet CSV;

date,start,stop,description

%F,%R,%R,DESCRIPTION

... which can be quickly modified via the following sequence of steps;

  • Normal mode

    • G normal mode we can jump to the end of the buffer
    • yy to yank the whole line
    • gg to jump to the top of the buffer
    • P to put/past before cursor position
    • v to enter Visual select mode
  • Visual mode

    • t,; select till comma (,) and ; to repeat once
    • <Leader>R
    • selected %F,%R text will be replaced via strftime built-in function

Note; mode will automatically switch to Normal

Example result

date,start,stop,description
2023-03-18,14:04,%R,DESCRIPTION

%F,%R,%R,DESCRIPTION

Insert and append examples

By default Normal mode <Leader>t (or T), and <Leader>d (or D), motions will append or insert the current time or date respectively.

Tip; this can be useful in combination with Ctrl^o from Insert mode to avoid breaking one's flow of thought.

Consider the following text;

I will see you later today (

... which may have current date appended via the following sequence of steps;

  • Insert mode

    • Ctrl^o
  • (insert)/Normal mode

    • <Leader>d
  • Insert mode

    • ) to discuss something

Example result

I will see you later today (2023-03-18) to discuss something

Notes

This repository may not be feature complete and/or fully functional, Pull Requests that add features or fix bugs are certainly welcomed.


Contributing

Options for contributing to date-time and vim-utilities


Forking

Start making a Fork of this repository to an account that you have write permissions for.

cd ~/git/hub/vim-utilities/date-time

git remote add fork [email protected]:<NAME>/date-time.git
  • Commit your changes and push to your fork, eg. to fix an issue...
cd ~/git/hub/vim-utilities/date-time


git commit -F- <<'EOF'
:bug: Fixes #42 Issue


**Edits**


- `<SCRIPT-NAME>` script, fixes some bug reported in issue
EOF


git push fork main

Note, the -u option may be used to set fork as the default remote, eg. git push -u fork main however, this will also default the fork remote for pulling from too! Meaning that pulling updates from origin must be done explicitly, eg. git pull origin main

  • Then on GitHub submit a Pull Request through the Web-UI, the URL syntax is https://github.com/<NAME>/<REPO>/pull/new/<BRANCH>

Note; to decrease the chances of your Pull Request needing modifications before being accepted, please check the dot-github repository for detailed contributing guidelines.


Sponsor

Thanks for even considering it!

Via Liberapay you may [![sponsor__shields_io__liberapay]][sponsor__link__liberapay] on a repeating basis.

Regardless of if you're able to financially support projects such as date-time that vim-utilities maintains, please consider sharing projects that are useful with others, because one of the goals of maintaining Open Source repositories is to provide value to the community.


Attribution


License

Commands for injecting date and/or time into current buffer
Copyright (C) 2023 S0AndS0

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
by the Free Software Foundation, version 3 of the License.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU Affero General Public License for more details.

You should have received a copy of the GNU Affero General Public License
along with this program.  If not, see <https://www.gnu.org/licenses/>.

For further details review full length version of AGPL-3.0 License.

About

Commands for injecting date and/or time into current buffer

Resources

License

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Sponsor this project

Packages

No packages published