I have Lightline installed for a more detailed statusline. Unfortunately, any time I do something like this

set statusline+=%{strftime(\"%H:%M\")}

it seems like Lightline will override it, and it won't show up.

When I tried adding this to the dictionary

'currenttime': '%{strftime(\"%H:%M\")}',

it didn't work. So I haven't been able to add the clock in a lightline compatible way.

I saw a post for how to add the battery level, which would be very helpful as well, since I am typically using Vim in fullscreen mode on monitor 1, and only monitor 1 has the battery level. How would I integrate these two while keeping the lightline statusline?

  • Use the plugin's documentation and issue tracker.
    – romainl
    Commented Oct 1, 2023 at 7:21
  • Welcome to Vi & Vim SE. To keep things focused, it might be better to have one question for the clock and one for the battery level. If you already found "a post", please share a link. It might help somebody to come up with a solution.
    – Friedrich
    Commented Oct 2, 2023 at 12:18
  • Do you still have something open in your question? How can we help your further? Otherwise maybe could you accept one of the answers using the v button next to the arrow voting buttons. It allow the question to rest :-) Commented Oct 12, 2023 at 14:28

1 Answer 1


I would do:

    function! MyHour()
      return strftime("%H:%M")

    let g:lightline = {
          \ 'active': {
          \   'left': [ [ 'mode', 'paste' ],
          \             [ 'readonly', 'filename', 'modified' ] ],
          \ 'right': [ [ 'hour' ],
          \            [ 'lineinfo' ],
          \            [ 'percent' ],
          \            [ 'fileformat', 'fileencoding', 'filetype' ], ]
          \ },
          \ 'component_function': {
          \   'hour': 'MyHour',
          \ },

Where the important parts are:

  • Add the [ 'hour' ] list to the list of right component of the g:lightline variable
  • Add the MyHour to the hour component of the component_function of the g:lightline variable
  • Add the definition of the MyHour function that returns the hour formatted.


  • The right component of the g:lightline is a list of list of the components you would like to see at the right side of the status bar (the first list correspond the most right components, the last list correspond to the least right components).
  • The element of the list ('hour' in our example) must correspond to either a standard component like 'mode' or to a component defined in the 'component_function' component of the g:lightline variable.

For the battery usage you can use the following battery plugin.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.