{"id":817,"date":"2020-12-31T19:38:37","date_gmt":"2020-12-31T18:38:37","guid":{"rendered":"https:\/\/pmortensen.eu\/world2\/?p=817"},"modified":"2023-03-29T17:53:58","modified_gmt":"2023-03-29T16:53:58","slug":"block-column-mode-in-text-editors-geany-visual-studio-ultraedit-notepad-and-visual-studio-code-and-vim","status":"publish","type":"post","link":"https:\/\/pmortensen.eu\/world2\/2020\/12\/31\/block-column-mode-in-text-editors-geany-visual-studio-ultraedit-notepad-and-visual-studio-code-and-vim\/","title":{"rendered":"Keyboard-only use of block\/column mode in different text editors (Geany, Visual Studio, UltraEdit, Notepad++, Visual Studio Code, Vim, and Emacs)"},"content":{"rendered":"<p>Although it is often somewhat hidden, most text editors, except for the most basic ones, have a column mode (also known as block mode or visual mode) &#8211; to <strong><em>work on rectangular selections of text<\/em><\/strong> (including a width of zero).<\/p>\n<p>Even more hidden is if it is possible to avoid using the mouse. In particular, Alt + mouse movement in <a href=\"https:\/\/en.wikipedia.org\/wiki\/Microsoft_Visual_Studio\">Visual Studio<\/a> will make a block selection, but this increases the risk of <a href=\"https:\/\/en.wikipedia.org\/wiki\/Repetitive_strain_injury\">RSI<\/a>. It is also impractical as the mouse must be used very precisely in both directions.<\/p>\n<p>It turns out all the text editors considered here have a way to <em>exclusively<\/em> use the keyboard for column mode operations.<\/p>\n<h2>Geany<\/h2>\n<p>In <a href=\"https:\/\/en.wikipedia.org\/wiki\/Geany\">Geany<\/a>, <kbd>Shift<\/kbd> + <kbd>Alt<\/kbd> + <kbd>arrow keys<\/kbd> will make a block selection and thus effectively enter into column mode.<\/p>\n<p>On Windows and Linux. It was tested with version 1.36 (Windows) and version 1.36 (Linux).<\/p>\n<p>On <a href=\"https:\/\/en.wikipedia.org\/wiki\/Lubuntu\">Lubuntu<\/a> (and <a href=\"https:\/\/en.wikipedia.org\/wiki\/Xubuntu\">Xubuntu<\/a>?), the keyboard shortcuts do not work, because they conflict with four default keyboard shortcuts in the window manager (<a href=\"https:\/\/en.wikipedia.org\/wiki\/LXDE\">LXDE<\/a>? <a href=\"https:\/\/en.wikipedia.org\/wiki\/Openbox\">Openbox<\/a>?), <kbd>Shift<\/kbd> + <kbd>Alt<\/kbd> + <kbd>arrow up<\/kbd>, <kbd>Shift<\/kbd> + <kbd>Alt<\/kbd> + <kbd>arrow down<\/kbd>, <kbd>Shift<\/kbd> + <kbd>Alt<\/kbd> + <kbd>arrow left<\/kbd>, and <kbd>Shift<\/kbd> + <kbd>Alt<\/kbd> + <kbd>arrow right<\/kbd>. Disable them by editing file <em>~\/.config\/openbox\/lubuntu-rc.xml<\/em> near &#8220;S-A-Up&#8221;, &#8220;S-A-Down&#8221;, &#8220;S-A-Left&#8221;, and &#8220;S-A-Right&#8221;. For example, change &#8220;S-A-Up&#8221; to &#8220;S-A-Up99&#8221;, &#8220;S-A-Down&#8221; to &#8220;S-A-Down99&#8221;, &#8220;S-A-Left&#8221; to &#8220;S-A-Left99&#8221;, and &#8220;S-A-Right&#8221; to &#8220;S-A-Right99&#8221;, respectively. And add an XML comment as to why and document the original values (so they can more easily be reverted). Edit and update (without a restart required):<\/p>\n<pre class=\"brush: perl; gutter: false; title: ; notranslate\" title=\"\">\r\nvi ~\/.config\/openbox\/lubuntu-rc.xml\r\nopenbox --reconfigure\r\n<\/pre>\n<h2>Visual Studio<\/h2>\n<p>In Visual Studio, Shift + Alt + arrow keys will make a block selection.<\/p>\n<p>On Windows only. It was tested with <a href=\"https:\/\/en.wikipedia.org\/wiki\/Microsoft_Visual_Studio#2012\">Visual&nbsp;Studio&nbsp;2012<\/a> (yes, I know).<\/p>\n<h2>UltraEdit<\/h2>\n<p>In UltraEdit, it is a mode that must be entered first: Alt + C (for menu <em>Column<\/em> &rarr; <em>Column Mode<\/em>). Then normal selection works (Shift + arrow keys, etc.) &#8211; in this case, block selection.<\/p>\n<p>On Windows and Linux. It was tested with version 16.2 (listed as &#8220;16.20&#8221;).<\/p>\n<h3>Special features in UltraEdit<\/h3>\n<p>The <em>same<\/em> text (e.g., a single word) from the <em>clipboard<\/em> can be inserted (in an empty column selection), in addition to being typed (so it is not necessary to retype the text). Thus after the paste the same text is now in all rows of the selection. <\/p>\n<p>This is, e.g., not possible in Geany. The workaround is to prepare the text beforehand, producing the number of lines matching the number of rows in the selection and copy-paste those lines.<\/p>\n<h2>Notepad++<\/h2>\n<p>In <a href=\"https:\/\/en.wikipedia.org\/wiki\/Notepad%2B%2B\">Notepad++<\/a>, Shift + Alt + arrow keys will make a block selection.<\/p>\n<p>Note that it is blinking a lot when going over empty lines.<\/p>\n<p>On Windows only. It was tested with version 7.9.1.<\/p>\n<h2>Visual Studio Code<\/h2>\n<p>In <a href=\"https:\/\/en.wikipedia.org\/wiki\/Visual_Studio_Code\">Visual Studio Code<\/a>, it is much more tricky (not intuitive, inflexible and does not work as described in the documentation). The beginning is also not the same on Windows and Linux.<\/p>\n<p>For Windows:<\/p>\n<p>Use three modifier keys, <em>Ctrl<\/em> + <em>Shift<\/em> + <em>Alt<\/em> + arrow key down (or arrow key up). This puts it into column mode (with a column empty selection of two lines).<\/p>\n<p>For Linux (this is very similar to Geany, Visual Studio, and Notepad++):<\/p>\n<p>Press <em>Shift<\/em> + <em>Alt<\/em> + arrow key down (or arrow key up). This puts it into column mode (with a column empty selection of two lines).<\/p>\n<p>The rest is common for Windows and Linux:<\/p>\n<ol>\n<li>Extend the selection to the desired number of <strong><em>rows<\/em><\/strong> (down or up). They must be selected before the columns.<\/li>\n<li>Lift the <em>Ctrl<\/em> key (as <strong><em>word<\/em><\/strong> selection would be the result in the next step &#8211; and the selection would be uneven (not a pure block)). Optionally also lift the <em>Shift<\/em> key.<\/li>\n<li>Extend the selection in the <strong><em>horizontal<\/em><\/strong> direction (to select the number of columns) by pressing the <em>Shift<\/em> key and the left or right arrow key.<\/li>\n<li>After operations using the block selection, the block selection mode can be exited by pressing the <em>Esc<\/em> key. Alternatively, the empty column selection (the number of columns stay the same) can be moved by the arrow keys (even up and down).<\/li>\n<li>Note that the <em>Ctrl<\/em> key works as an alternative to the <em>Alt<\/em> key.<\/li>\n<\/ol>\n<p>Note that there is less freedom in how the block selection takes place. First the number of rows must be selected and then the number of columns. <\/p>\n<p>Also, it does not work as expected if some of the lines are short (selection in the horizontal direction is beyond the short line) &#8211; the selection will extend onto the next line, <strong><em>making it useless<\/em><\/strong>. In particular, it does not work over empty lines &#8211; a very severe limitation.<\/p>\n<p>On Windows and Linux. It was tested with version 1.43.1 (Windows) and 1.52.1 (Linux).<\/p>\n<p>In conclusion, block mode in Visual Studio Code is both cumbersome to use and <em>underdeveloped<\/em> (it does not work for as many use cases as all the other editors presented here). Despite all the hype, Visual Studio Code has not matured.<\/p>\n<h2>Sublime Text<\/h2>\n<p><a href=\"https:\/\/en.wikipedia.org\/wiki\/Sublime_Text\">Sublime Text<\/a> is similar to the broken Visual Studio Code (e.g., with an initial  column empty selection of two lines) and is unintuitive to use.<\/p>\n<p>To start, press <em>Shift<\/em> + <em>Alt<\/em> + arrow key down (or arrow key up). <\/p>\n<p>This was tested on Linux, with the default editor in <a href=\"https:\/\/pmortensen.eu\/world2\/2023\/03\/13\/arcolinux-23-02-installation-blues\/\">ArcoLinux<\/a> (an <a href=\"https:\/\/en.wikipedia.org\/wiki\/Arch_Linux\">Arch Linux<\/a> derivative).<\/p>\n<h2>Vim<\/h2>\n<p>In <a href=\"https:\/\/en.wikipedia.org\/wiki\/Vim_%28text_editor%29\">Vim<\/a>, it is a mode that must be entered first: Alt + V. In Vim speak, it is called &#8220;visual mode&#8221;. Then using the arrow keys (and other movement) will make a block selection.<\/p>\n<p>On Windows, Linux, and Raspberry Pi. It was tested with <!-- version X.XX (Windows), --> version 8.1 (Linux, 2018) and version 7.3 (Raspberry Pi, 2010).<\/p>\n<p>Note that this also works for a first-generation <a href=\"https:\/\/en.wikipedia.org\/wiki\/Raspberry_Pi\">Raspberry Pi<\/a> over an <a href=\"https:\/\/en.wikipedia.org\/wiki\/Secure_Shell\">SSH<\/a> connection (but the name of the executable is &#8216;vi&#8217;, not &#8216;vim&#8217; &#8211; though it is actually Vim that runs).<\/p>\n<h2>Emacs<\/h2>\n<p>In <a href=\"https:\/\/en.wikipedia.org\/wiki\/Emacs\">Emacs<\/a>, <kbd>Ctrl<\/kbd> + <kbd>X<\/kbd>, <kbd>Space<\/kbd> to start. Move the cursor to the end of the block\/column selection (for example, by the arrow keys). The selection is invisible!<\/p>\n<p>Related blog post (for example, with version requirements and instructions for <em>casual<\/em> use of Emacs): <em><a href=\"https:\/\/pmortensen.eu\/world2\/2020\/11\/11\/building-emacs-from-source-on-ubuntu-20-04\/\">Building Emacs from source on Ubuntu 20.04 in 2020<\/a><\/em><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Although it is often somewhat hidden, most text editors, except for the most basic ones, have a column mode (also known as block mode or visual mode) &#8211; to work on rectangular selections of text (including a width of zero). &hellip;<\/p>\n<p class=\"read-more\"> <a class=\"more-link\" href=\"https:\/\/pmortensen.eu\/world2\/2020\/12\/31\/block-column-mode-in-text-editors-geany-visual-studio-ultraedit-notepad-and-visual-studio-code-and-vim\/\"> <span class=\"screen-reader-text\">Keyboard-only use of block\/column mode in different text editors (Geany, Visual Studio, UltraEdit, Notepad++, Visual Studio Code, Vim, and Emacs)<\/span> Read More &raquo;<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[17,23,18,24],"tags":[],"_links":{"self":[{"href":"https:\/\/pmortensen.eu\/world2\/wp-json\/wp\/v2\/posts\/817"}],"collection":[{"href":"https:\/\/pmortensen.eu\/world2\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/pmortensen.eu\/world2\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/pmortensen.eu\/world2\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/pmortensen.eu\/world2\/wp-json\/wp\/v2\/comments?post=817"}],"version-history":[{"count":78,"href":"https:\/\/pmortensen.eu\/world2\/wp-json\/wp\/v2\/posts\/817\/revisions"}],"predecessor-version":[{"id":3489,"href":"https:\/\/pmortensen.eu\/world2\/wp-json\/wp\/v2\/posts\/817\/revisions\/3489"}],"wp:attachment":[{"href":"https:\/\/pmortensen.eu\/world2\/wp-json\/wp\/v2\/media?parent=817"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/pmortensen.eu\/world2\/wp-json\/wp\/v2\/categories?post=817"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/pmortensen.eu\/world2\/wp-json\/wp\/v2\/tags?post=817"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}