Showing posts with label vim. Show all posts
Showing posts with label vim. Show all posts

This Week I Learned - 2017 Week 42

Last week post or something from the archive.

Sweet old week 42. Another ten more weeks and we can conclude the year 2017. Things are getting more exciting. Switching different diet seemed to help somehow, even the complexion of old wounds was getting better.

21 years. That's is probably the longest overdue to-do item I've checked off this week. When I was young, Japanese Drama was a regular slot our local TV channel TV2. There was this drama and song which I partially remembered but can't remember the name or the casts. The tune have been humming inside my head for the past 21 years.

While building a play list of songs to test different amplifier or speakers, I stumbled upon a list old 90's Japanese opening theme songs. The first song on the list was the bloody tune that have been lingering in my mind for so long. The name of the song is "Ima Sugu Kiss Me (今すぐkiss me)" sang by the pop/rock band, Lindberg. You can safely ignore the awkward 90's fashion sense and MTV style. And the name of the drama is "Sekai de Ichiban Kimi ga Suki (世界で一番君が好き!)".

Dreyfus model of skill acquisition. One of the issue when picking up new skill is you may stuck at the advanced beginner level and can't move on to the next level. The joke about having ten years experience but doing the same thing ten times clearly illustrates this sad but truth scenario. How you know you're stuck in the advanced beginner level? Observe your seniors who have work much longer than you. Refactor your wetware is one of the possible way to overcome this.

Philharmonic Audio Affordable Accuracy speakers. Some knowledge on electronic and speaker design does help to improve an existing good enough speakers to excellent level. Again, sadly we can't get the parts here in MY.

The Farmer's Horse by Alan Watts. Not really much about the lesson of the story but the origin of the story. I've read this story several times and there are several versions. Some believed this is an old Chinese parable but I don't remember reading this story in any ancient Taoism literature. There are always stories from second source rather than the primary source. I was wondering what is the primary source of the story?

Vim after 15 years. (via HN). Time to clean up my Vim configuration again.

The ES9038PRO DAC chip (details from manufacturer). Never buy product by the brand, always look into the component used. Compare the specifications and features and purchase according to your budget. However, product based on this DAC chip is still rather expensive. Can't wait to get myself on any cheaper DACs based on this chip from China to test it out like the TFT HifiDuino project. Comparable, you also can get DAC using the AK4497EQ chip.

This Week I Learned - 2017 Week 34

Last week post or the old archive stuff.

Having a working and non-disrupting battle station have finally let me able to concentrate on my personal stuff. There are a lot of things to clean up and de-clutter but one thing at a time. At least I can sync up the productivity at both work and home.

Lots of re-learning of ConTeXt, after so many years away from it. The number one rule in using ConTeXt, you must append a comma (,) in a list of items. Not sure why, but I was burned several times where the intended results were not obtained regardless numerous times of trials and errors.

This will not work.

This will work.

Undo certain Git commit. Two steps involved. First is to reset or remove the particular commit and push the changes to remote origin. Second, pull from the remote origin and reset the index.
$ git reset 7f6d03 --hard
$ git push origin -f

$ git fetch origin
$ git reset 7f6d03 --hard

Finally, found the effective way of managing your dotfiles and the full write-up describes the details on how to set it up, either new or existing Git repository. Good example where the lack of understanding of Git undermines the effective usage of managing your dotfiles. There is no need for external programs to manage your symlink and updates. Just plain old Git. The hassle and complexity of managing your development environment setups (I've tried a few ways) is not worth the time and efforts.

People, this is how you design a login or registration form.

Installed, uninstalled, and reinstalled the Vim package. Somehow the path to Vim binary have been messed up. However, update the Bash's hash table of full path names of executable files seems to solve it.
$ vim
-bash: /usr/local/bin/vim: No such file or directory

$ which -a vim

$ hash -r

Somehow my Vim installation does not support Python plugins. Some googling here and there revealed that I have multiple implementation of Vim installed in the system. The default selected Vim binary does not support Python plugins. The only way is to update the alternative.
$ sudo update-alternatives --config vi
There are 3 choices for the alternative vi (providing /usr/bin/vi).

  Selection    Path               Priority   Status
* 0            /usr/bin/vim.gtk3   50        auto mode
  1            /usr/bin/nvi        20        manual mode
  2            /usr/bin/vim.gtk3   50        manual mode
  3            /usr/bin/vim.nox    40        manual mode

Press  to keep the current choice[*], or type selection number: 3
update-alternatives: using /usr/bin/vim.nox to provide /usr/bin/vi (vi) in manual mode

$ sudo update-alternatives --config vim
There are 2 choices for the alternative vim (providing /usr/bin/vim).

  Selection    Path               Priority   Status
  0            /usr/bin/vim.gtk3   50        auto mode
  1            /usr/bin/vim.gtk3   50        manual mode
* 2            /usr/bin/vim.nox    40        manual mode

Press  to keep the current choice[*], or type selection number: 2

People start hating their jobs at age 35? (via HN) The best possible reason is that they become very aware of mortality and realize time move at a relatively faster pace.

How the RPi::WiringPi distribution is tested. You have to be amazed by the effort the author is putting in ensuring the quality of the libraries. Probably one the most meticulous developer I've seen online. The hardware setup is shown in the screenshot.

Don't like any ready-build electronic prototyping platforms? You can try Shrimp parts kits. I love the minimalist approach of gathering different electronic components and build something up. Good alternative to Arduino. The step-by-step guidance, for example, to blink an LED, is a good introduction for any beginner (yours truly) who want to pick up some electronic.

This Week I Learned - 2017 Week 15

Last week post or you can browse through the whole series.

While debugging a Makefile, I accidentally `rm -rf` my home folder. Lesson learned, always backup and sync your changes regularly. Nevertheless, it's always a good fresh start when your home folder contains not a single file or folder. Good that you have a weekly clean up of your machine, review, keep, or remove. Otherwise, there will be a lot of pending left over files.

It has been a while since I work on weekend. The serenity of the environment did improve your productivity ten-folds. There is no sounds other than the air-con, traffic, and your typing sounds. You're basically in the zone, focus solely on the task at hand. No more stupid shenanigan. In hindsight, you have to find or create your own optimal environment and zone. It all starts with a system that leads to a habit, good habits.

#1 How to read more books? Lots of good tips and increasing the volume of books you can read. It's already early April and I only managed to finish 2 books. Not really on track on finishing 12 books this year. Thinking back, reading style, book choices, timing, and context are what causing the slowness. One of the best strategy is to switch different books if you're stuck or bored. Some books need more mental energy to go through it. While reading 2 pages per day can develop a good habit, it's not sufficient fast enough to catch up with my pilling reading list.

#2 Engineer's Disease. The unconscious thought that can lead to arrogant and condescending personality. Maybe because such behaviour "stems from the OCD and emotional detachment our peoples tend to have, mixed in with a good dose of raging insecurity"? Good forum discussions to ponder upon, especially by those working in software development.

#3 Does teenager and adult have different learning capability? Time, available perceived time. Also discipline, attention, and focus. The discussion at HN gave a lot of strategies to attack the problem. Simple daily practice and learning together with different learning strategies. What to learn then? Fundamental. There is an interesting discussion on software development being a dead-end job after 35-40.

#4 On understanding the fundamental of Vim. Before you install any Vim's plugin, best to learn what the default features exists or not.

#5 System Design Primer. If you want to learn how to design large scale systems. However, premature optimization is still evil. Knowing something can be done right doesn't means it should be done now. There are always contexts and constraints. Solutions looking for problems always end up wasting everyone resources. This HN user's experience on scaling your system accurately illustrates such scenario.

#6 Looking busy at work?. Most people don't realize that pretend to work and look busy is actually far more harder than doing the actual work. Faking will deplete you psychologically as your thoughts, actions, and words are not in sync. However, there are always exception. Certain group of people thrive on such behaviour without caring for any forms of repercussion. While some just stuck with mind-numbing boring job. There is a saying by Napoleon Hill which states "If you are not learning while you’re earning, you are cheating yourself out of the better portion of your compensation.” Unless you're stuck with certain constraints, move on. You're not a tree!

#7 LXD finally available for Fedora. Not as native RPM package but through Snap. I'm going to reformat another workstation and install Fedora with it. One less reason to stick with Ubuntu. Only left the DEB package, which I believe, no way Fedora/CentOS/Red Hat is able to dethrone the number of available packages provided by Debian. I'm not looking for rolling release like Arch but availability of different software. Maybe Snap, the universal GNU/Linux package can change that?

This Week I Learned - 2017 Week 14

Last week post or you can go through the whole series.

Proposal have been presented and submitted. Standard feedback received. Nevertheless, better than nothing regardless the quality of the reactions.

#1 GTCafe Studio. Stumbled upon this site while searching for different covers of Guthrie Govan's Emotive Ballad. It's rare these days to find any blog with original good content. Reading through his journal on learning guitar made me reflect back on my decision on donating all my guitars away few years back. Maybe is time to start all over again? Or maybe not? Learning to play an musical instrument is one of the way to escape from mind-numbing daily routines. However, there is a time and place for everything in life. In hindsight, sometimes you just have to move on.

#2 "CentOS is not stable, it is stale". So true that it hurts. For me, as a whole, Fedora provides a better desktop experience than Ubuntu. Yet, I still revert back to Ubuntu on my daily usage. Why? APT is definitely better than YUM and plenty of software selection. Furthermore, LXD works only in Ubuntu and not Fedora. And yes, finally Canonical realized that and declared Ubuntu Unity will be replaced by Gnome 18.04 LTS. Maybe this Ask HN post on feedback for Ubuntu 17.10 from the community have finally sealed the fate for Unity?

I always wonder what would happen if Red Hat decided to use build a distro based on Debian or DPKG package manager instead of creating their own RPM packaging manager? A unified GNU/Linux desktop will come sooner rather than unnecessary fragmentation and efforts. For example, the competition of next generation display server of Mir and Wayland. Yes, I know having options and competitions is good for progress. But the priority and effort should be on fixing the damn display drivers performance and stability issues. Fragmentation leads to duplication of works.

#3 Five great Perl programming techniques to make your life fun again. An old article, 11 years ago but everything described there is as relevant as today especially iteration using `map` and `grep` and Dispatch Table as illustrated in example below. As Perl does not have `switch` statement, hence using Dispatch Table is a good Perl design patternMark Jason Dominus, in his book, Higher-Order Perl also devoted a whole chapter (PDF) on this matter.
my $dispatch_for = {
   a => \&display_a,
   b => \&display_b,
   q => sub { ReadMode('normal'); exit(0) },
   DEFAULT => sub { print "That key does nothing\n"; },

my $func = $dispatch_for->{$char} || $dispatch_for->{DEFAULT};

#4 Perl 5 Internals (PDF). Interesting reading on the intricacy part of the Perl itself. It was brought to my attention that Perl is a bytecode compiler, not an interpreter or a compiler.

#5 The 'g' key shortcuts in Vim. You will learn something new everyday, there are so many key bindings. Surprisingly, I only knew and regularly use two. Really needs to refresh and relearn this.

This Week I Learned - 2016 Week 44

Last week post or the whole series.

Every time I reread Perl in about 2 hours 20 minutes, there is always new insights that increase my understanding of Perl itself. I can finally grok the intricacy of the three data types: scalar, array, and hash, especially the later two. To make it short, don't use list as container for arrays or hashes, just initialize and declare both types as anonymous array(using bracket) or hash (using braces). You can use them through reference or arrow (`->`) operator. Example as shown.
use v5.10;

my $contact = {
    name => 'John Doe',
    mobiles => [
        {carrier => 'at&t', no => '111-222-333'},
        {carrier => 't-mobile', no => '444-555-666'}

say $contact->{mobiles}->[0]->{carrier}; # at&t
say $contact->{mobiles}->[1]->{carrier}; # t-mobile

Another key concept is Perl calls by reference. This means when you pass a variable to a subroutine, it's a reference to the original value, not a copy. Any modification to the variable, will be reflected within the scope or context of the code until the end of the execution. The most important takeaway is that arguments to the subroutine is a list of scalar (yes, the @_ is a list) and the element of @_ is an alias to the passed parameters. According to perlsub documntation (emphasis added),
Therefore, if you called a function with two arguments, those would be stored in $_[0] and $_[1] . The array @_ is a local array, but its elements are aliases for the actual scalar parameters. In particular, if an element $_[0] is updated, the corresponding argument is updated (or an error occurs if it is not updatable). 

While we are on Perl (yes, we still talking about it). What are the preferred ways to check if an element exists in an array? Two most common way. One is using the default grep method, another is using the `List::MoreUtils` method.
# using grep
if (grep { $_ eq $element } @list) {

# using List::MoreUtils
use List::MoreUtils qw(any);
if ( any { $_ eq $element } @list ) {

My migration back to Vim from Sublime Text seems to be progressing quite well. It's nice to expose yourself to another editor and reapply certain features back to your default editor. First, is update tmux tab with Vim's opened file name. This was one of those things that you want to fix it, but never remember to do so. Next, fix copying from clipboard in Windows not working issue. Next, set indentation rules (like tab only) by file type. And lastly, how to open most recent opened files. Something I didn't realize exists in the default settings.

Remember Lorem Ipsum? Which is commonly used as filler text or place holder text in graphic design before the actual content is used. Well, this process is also known as Greeking. In Perl, there is this module, Text::Greeking, which provides such feature. There are others as well, like the usual Text::Lorem. But nothing can compare to the sheer bullshit of Lingua::ManagementSpeak which can generate meaningful sentences but pure bullshit management speak.

"a web browser is a JS interpreter". So true. Maybe I should start looking into all these "ancient" technologies (e.g. Tcl/Tk) instead of chasing latest greatest fad.

Is always a grey area if you choose to do development work in either porn or gambling industry. But I never realize that advertising industry is as shady as well.

Hate to be prompted for password every time you need to commit to Git repository through SSH? Save some typing by caching the credential. There are two ways.

Through SSH.
$ eval `ssh-agent -s`
$ ssh-add ~/.ssh/id_rsa_key
$ ssh-add -l
$ ssh

Through Git.
$ git config --global credential.helper cache

This Week I Learned - 2016 Week 36

Last week post or you might want to check out the whole series.

Some findings around the Internet.

XKCD-style graph using Matplotlib? In Ubuntu, you'll need to install these fonts to get the closest possible rendering.
$ sudo apt-get install ttf-mscorefonts-installer fonts-humor-sans
$ rm -rf ~/.cache/matplotlib/fontList.cache

Using Matplotlib without X-server? Switch to Agg backend. Useful when you're rendering image through Docker container.
import matplotlib as mpl
import matplotlib.pyplot as plt

Sigh. Unresolved ImageMagick bug in most recently releases including the LTS, which text conversion still causing core dump. Switching to GraphicsMagick, a fork of ImageMagick did not resolve the issue as command line options have both diverted. My research made me aware that both tools were being used to massively batch process images in a very large scale.

Sometimes, the default Vim configurations/features is good enough without installing buggy extensions. We're relying too much on the external plugins without utilizing the fullest features of Vim itself.

Old time PHP developer switching to Perl? You should read this Reddit's post. The advice given was spot on and correlates with my own personal experience. Nothing against PHP, but in our journey to become a better developer, you'll need to expose yourself to other programming languages and environments. Otherwise you'll end up like those developer who claimed to be a ten-plus years developer but actually doing the same development development work for a year but repeated ten times. I will write another blog post on this in coming future.

"To finish projects on time, start every single step as late as possible" via HN. Full text of all the twitter posts. Catching and provocative statement coming from Tiago Forte, a productivity consultant. Despite the click bait title, HN user, bmh100 interpret his message correctly. Keywords here is "critical path". In other words, is Critical Chain Project Management. Sometimes I wonder is procrastination due to lack of awareness of a task? Or to rephrase it, procrastination is a mindfulness problem? Without awareness, there is no estimation and prioritization, hence the task will be postponed repeatedly or not completed within the time frame?

This Week I Learned - 2016 Week 27

Looking back to the last week post or you might want to check out the whole series.

What is Modern Perl? (via HN). The transition of Perl development motto from TMTOWTDI (pronounced Tim Toady) to TIMTOWTDIBSCINABTE (Tim Toady Bicarbonate). It took them (the Perl community) quite a long time to realize that consistency is not a bad things. Some approaches are really preferable but at least there should be a consistency way of coding, hence coding convention should and would exists in a project or a team.

REPL for Perl? Well, you will have to install Devel::REPL with some customization and workaround. To get started, just install these modules and run these commands.
# Prevent Data::Dump::Streamer failed to install error.
# See
$ cpanm PadWalker 

# Enable command history
# See
$ cpanm Term::Readline::Gnu 

# Install the REPL
$ cpanm Devel::REPL

# Run the REPL

# Find the Perl version through '$]' and '$^V' Perl's variables.
$ $]

$ $^V

# Quit from the REPL.
$ exit

How X11 works. Wonderful guide on underlying structure of X Windows System.

Free Perl programming books. Didn't realize there are still a lot of unknown, although quite old, Perl books.

Do you suffer from compulsive hoarding? Then r/datahoarder is for you. Be warned, you will burn some extra money to collect these data.

Probably the minimum Vim settings (compare to this and this) to have a good usage experiences, especially when administrating a server through the console.

How to write defensive Bash script. There is always one rule that I never follow, whic is to explicitly make all variables 'local'. Not a good habit if you want to be proficient at console.

It's the future. Be aware of over-engineered and complex solutions for your application before you decide to adopt it to your technology stack.

Awesome list of Perl resources. While we're at it, should you still use Perl?

It has been a while since I last follow with any CSS standard. For me, the existence of CSS frameworks means that the CSS is a solved issue for web development. One thing I noticed that the CSS box-model have changed these days till we have International box-sizing awareness day which the default 'box-sizing' should be 'border-box'. It seems that the Internet Explorer was rights about the default box calculation.

This Week I Learned - 2016 Week 21

Write-up for last week or you might want to read the whole series.

My time with Rails is up. This sure brings back the memory of Zed Shaw's infamous rant post, Rails is a Ghetto. I think the author major issue is Ruby on Rails tight coupling architecture. I can understand why he prefers building web application from a bunch of independent libraries (more like Unix's philosophy of 'Do One Thing and Do It Well' approach). This is Gartner's Hype Cycle at work here and this excellent reply provides another point of view and suggestions. What's next in Ruby land if you want to build a web application but not using Rails? Traiblazer, Hanami, ROM, and dry-rb. One good thing the came out from all the Rails hype was that more developers were made aware of PostgreSQL instead of the default MySQL.

How I Vim. Interviews of Vim's user on how they customized and use Vim. Due to the recent changes in life, I've been evaluating Sublime Text and have a different perspective and understanding on why this editor was popular among non-Unix users. There is nothing unique about Sublime Text that both Vim or Emacs can't reproduce. The only things missing in both these legacy editors is good sensible default. For examples, searching multiple files or jumping through definitions without resorting to external plugins and customization.

Remember that you always search for "asdfasdksfdasdf" just to clear the highlighted search results, even after restarting the Vim? There is a way, although still manual, to toggle off the highlighted search. This is coming from :best of Vim.
nnoremap  / :nohlsearch

Again, another unsolved Vim's customization cleared today! Auto-reload your '.vimrc' file upon saving.
augroup reload_vimrc
    autocmd BufWritePost $MYVIMRC source $MYVIMRC
augroup END

The machine is acting up again and I can't get anything much done today. Most probably it has reaches its end of life. Maybe is time to get a new machine instead.

This Week I Learned - 2016 Week 16

Write-up for last week or you might want to read the whole series.

Using short URLs when sharing document through OneDrive or Google Drive? Think twice. Researchers have managed to brute force short URLs within six characters to obtain the content.

Ubuntu 16.04 (Xenial Xerus) finally released (Vagrant box download here). The is the LTS release that going to replace the 14.04 (Trusty Tahr) and by looking at the release notes, there are so many upgrades, especially LXD 2.0 (more on other features in coming post). However, there is one feature that everyone is yearning on for so many year. We can now move the launcher to the bottom of the screen ! Hooray ! The funny thing is after so many years of yearning for such feature, I'm getting used of the launcher on the left. How ironic is that?
$ gsettings set com.canonical.Unity.Launcher launcher-position Bottom # to the bottom
$ gsettings set com.canonical.Unity.Launcher launcher-position Left # to the left

While we're on Ubuntu, another new feature added was Snap package format. However, was seems to be not secure at all as made known by Matthew Garrett. While I'm not sure how this things works, is best to avoid installing any Snap packages.

Talking to a dying person. Pieter Hintjens, the programmer of ZeroMQ, distributed messaging, has been diagnosed with incurable cancer. The best way to talk about this is to remind the patient about the good old days or experience both of you have together. Remind and cherish the memory you have together.

Particular case of renaming files? Didn't realize that renameutils exists. Basically running the 'qmv' command will fire up your editor and let you change the file names as you wish.

I've been tinker with Emacs these days and the ironic part is I've become a more informed Vim user. If you want to save a portion of file to external file and delete it at the same time, pipe it out through ':!cat > filename.txt'.

Surprise found in Youtube, Gundam Thunderbolt (ONA released) was probably the only Anime that caught my attention. Fluid animation (the drum solo), Jazzy music (kind of remind you of Cowboy Bebop, someone even joked about this series as Gundam Bebop), face paced action, and character designDiscussions at Reddit share the same sentiment. All this reignites my interest for Mecha and Gundam Model Kit again.

The Road to Evil

Few years back, I've tried it but the transition experience still a lot to be desired. But due to the recent circumstance which piqued my interest to revisit this long overdue to-do item in my someday list again. Yes, to become an engaged member of the Church of Emacs.

Joke aside. With the recent development of Emacs and the more stable releases of its related plugins, the transition from Vim to Emacs seems doable and manageable. You still can retain most of the Vim experience in Emacs through Evil (Extensible Vi Layer for Emacs), but not without some additional customization. More on that in coming posts.

Installation in Ubuntu.
$ sudo apt-get install emacs24

$ emacs --version
GNU Emacs 24.5.1
Copyright (C) 2015 Free Software Foundation, Inc.
You may redistribute copies of Emacs
under the terms of the GNU General Public License.
For more information about these matters, see the file named COPYING.

Well, this is Ubuntu/Debian, checking the emacs binary. Maybe there other Emacs implementations available?
$ file $(which emacs)
/usr/bin/emacs: symbolic link to /etc/alternatives/emacs

$ file /etc/alternatives/emacs 
/etc/alternatives/emacs: symbolic link to /usr/bin/emacs24-x

$ sudo update-alternatives --config emacs
There is only one alternative in link group emacs (providing /usr/bin/emacs): /usr/bin/emacs24-x
Nothing to configure.

By default, Emacs starts with X window system. If you want to bypass this behaviour and start in console instead, use the '-nw' parameter or add an alias instead.
$ emacs -nw
$ alias emc='emacs -nw'

Next is to install the Evil package for Emacs. If you need something up fast, check out the blog post by Bling and his Evil-mode bootstrap config. There is also a tutorial video to demonstrate evil-mode in Emacs. Ironically, I learned more about Vim than Emacs from his video.

To automatically install missing packages, the '.emacs.d/init.el` as follows.
$ cat .emacs.d/init.el 
; required packages
(setq package-list '(evil))

; additional repository
(require 'package)
(add-to-list 'package-archives '("melpa" . ""))

; activate and refresh all the packages
(unless package-archive-contents

; install the missing packages
(dolist (package package-list)
  (unless (package-installed-p package)
    (package-install package)))

; enable evil-mode
(require 'evil)
(evil-mode 1)

Start Emacs in console but enable debugging. If there are no issues, Emacs will start normally and you can immediately start using it with Vim's default key bindings.
$ emacs -nw --debug-init

To prevent Repetitive strain injury (RSI), one the of way when using Vim is reducing your pinky or little finger usage. For the left pinky, the Escape (Esc) key and for the right pinky, the colon (:) key.

The Escape key.
This can be done by mapping 'jj' key to Escape key. Updates to our '.emacs.d/init.el' file.
$ cat init.el | grep "required\|exit" -A 3
; required packages
(setq package-list '(evil key-chord))

; additional repository
; exit insert mode by pressing j and then j quickly
(setq key-chord-two-keys-delay 0.5)
(key-chord-define evil-insert-state-map "jj" 'evil-normal-state)
(key-chord-mode 1)

Binding the Colon (:) key.
This can be achieved by binding the colon (:) key to semicolon (;) key. Thus remove the needs to use the right Shift key. Changes to '.emacs.d/init.el' as shown again.
$ cat init.el | grep "evil-ex" -B 1
; bind ';' to ':'
(define-key evil-normal-state-map (kbd ";") 'evil-ex)

Restart Emacs and both settings should be customized to our liking.

As someone who suffered from RSI (rare these days but still prevention is still better than cure), these two customization are the essential minimum requirements for me to have a painless typing sessions. Not sure why, but both these settings should be the sensible default to Evil-mode, not enable by default, but should be part of the settings.

Stay tuned, expect more Emacs customization posts in coming months.

Removing Staircase Effect in Vim

Name one of the repetitive manual work in your life right now?
I always have to toggle between paste and nopaste mode in vim to prevent misaligned source code indentation. This is also known as staircase effect.

Staircase effect? Tell me more about it.
Vim will assume all paste text is typed to the editor rather than paste. If autoindent is on, the editor will reindent the whole text again as illustrated by below screenshot.

Ok. How you going to reduce the manual typing?
Configure vim to use keyboard shortcut to reduce typing as described by this vim tip. In your .vimrc file, add these options.
" switch between paste and no paste mode fast and go into insert mode
" after that
let mapleader = ","
nnoremap p :set invpaste paste?i
set pastetoggle=p
set showmode

What the improvement?
Number of key press to copy and paste
Without keyboard shortcut : 21
With shortcut : 4

No Arrow Keys in Vim

" Get off my lawn
nnoremap  :echoe "Use h"
nnoremap  :echoe "Use l"
nnoremap  :echoe "Use k"
nnoremap  :echoe "Use j"

Interesting. Maybe I should put these lines into the dot file to prevent the intern from using the arrow keys?