I write my blog posts with Markdown and I have many files named with post titles. So, every time I am about to write a new post, I do:
% cd /path/to/ % touch 'New post.mkd' % vi !$
Quotation marks must be used because of spaces, Space is not a good alternate option. I would have to enter two single quote, then move my cursor in between them. I used to type two at once or I often forget to type the closing quote.
I decided to solve my problem. Its a problem because I dont want to move my hand to arrow keys, there probably have keys to move by characters using control key plus something, but I am not aware of. Anyway, I added the following to ~/.inputrc:
"\C-x\'": "'' \e[D\e[D" "\C-x\"": "\"\" \e[D\e[D"
I was wanting to use Ctrl+' but its not possible, it returns '. So I need an prefix and Ctrl+x seems to be an nice choice. Whenever I need quotes, I type Ctrl+x and ', or Ctrl+x and ", depends on what type of quotes I would need. Two quotes and one space will be placed, then the cursor will be moved in between quotes using \e[D.
You might be wondering why I append a space, the reason is simple. If I have additional argument need to put after the quotes, I can press Ctrl+Right (or just End) because I also have:
# Screen/tmux "\eOD": backward-word "\eOC": forward-word # xterm/urxvt "\e[d": backward-word "\e[c": forward-word
I dont need to move cursor out of quotes and type a space.
0 comments:
Post a Comment