Skip to content

Smart shift text left/right by current major mode indentation width.

Notifications You must be signed in to change notification settings

hbin/smart-shift

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 

Repository files navigation

MELPA

Smart Shift

Smart Shift is a minor mode for conveniently shift the line/region to the left/right by the current major mode indentation width or shift line/region backwardly/forwardly by lines.

Installation

Melpa

Once you have setup Melpa you can use package-install command to install. The package name is smart-shift.

Manual

(add-to-list 'load-path "/path/to/smart-shift")
(require 'smart-shift)
(global-smart-shift-mode 1)

Customizing

Smart Shift will infer the indentation level of current major mode, if none of major modes listed below match, use the tab-width as default.

It can also be set to a number explictly.

(setq smart-shift-indentation-level 2)

Or, for some major mode we haven't support, add following snippets to your config file. Test it and send a PR.

(eval-after-load 'your-major-mode
  '(progn
     (add-to-list 'smart-shift-mode-alist
                  '(major-mode-or-derived-mode . customize-base-offset))))

Supported major modes

  • lisp-mode
  • emacs-lisp-mode
  • c-mode
  • c++-mode
  • objc-mode
  • java-mode
  • idl-mode
  • pike-mode
  • awk-mode
  • ruby-mode
  • python-mode
  • swift-mode
  • js-mode
  • js2-mode
  • coffee-mode
  • css-mode
  • scss-mode
  • slim-mode
  • html-mode
  • web-mode
  • sh-mode
  • yaml-mode
  • text-mode
  • markdown-mode
  • fundamental-mode

Interactive commands

Command Keybinding Description
smart-shift-left C-C <left> Shift the line or region ARG times to the left.
smart-shift-right C-C <right> Shift the line or region ARG times to the right.
smart-shift-up C-C <up> Shift the line or region ARG lines backwardly.
smart-shift-down C-C <down> Shift the line or region ARG lines forwardly.

After invoking smart-shift-<arrow> the first time, you can simply hit the <arrow> key to continuously shift, respectively.

If you use the key-chord like me. I strongly recommend you add the following snippets:

(key-chord-define-global "<<" 'smart-shift-left)
(key-chord-define-global ">>" 'smart-shift-right)

Contribute

Forks and pull requests are welcome!

About

Smart shift text left/right by current major mode indentation width.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •