Tahir Hassan's Blog

My Technical Notes

Friday, 22 September 2017

Vim: Setting tab to insert 4 spaces

Stick this in `$MYVIMRC`:


set expandtab
set tabstop=4

The first line ensures that the tab is expanded to spaces, the second line tells us how many spaces a tab "consists" of.

Emacs Org-Mode: Setting Agenda Files List to Current File

To set `org-agenda-files` to the current file when it is opened, put this in your `init.el`:


(add-hook 'find-file-hook 'my-org-agenda-hook)
(defun my-org-agenda-hook ()
  (when (string= (file-name-extension buffer-file-name) "org")
    (setq org-agenda-files (list (buffer-file-name)))))

This is not recommended behaviour because if you were to open another file, the first file's name would no longer be in the list.

A better design would be to check if the list has a value, if not set it to a list with the file name, if so, then append an element to the end of the list.

Vim: f to jump to that char

f<char> to jump to first occurence of that character. Then semi-colon to repeat the last command to get to where you want to go. For example:

today is a rainy day
^

[fd]

today is a rainy day
  ^
  
[;]

today is a rainy day
                 ^

Also see this StackOverflow answer which describes the use of ct<char> to replace everything before that char with newly typed text.

Thursday, 21 September 2017

Vim: word wrap

To disable the hard-breaking of a line, set `textwidth` to `0`:


:set tw=0

Then set `linebreak`:


:set lbr

Emacs: Showing Logged work

  • `M-x org-agenda`
  • `a` for Agenda.
  • `v`, then `L`. to show logged work.

Friday, 15 September 2017

Thursday, 14 September 2017

Vim - Making the cursor not blink

To disable the cursor from blinking in normal mode (for example, to take screenshots), do:


:set guicursor+=n:blinkon0

This works in graphical Vim, not on command-line Vim.