How do I navigate the MiniBufExplorer without going into the MiniBufExplorer window? - keyboard-shortcuts

How do I navigate the MiniBufExplorer without going into the MiniBufExplorer window?
In lines 170-174 of minibufexpl.vim:
" To enable the optional mapping of <C-TAB> and <C-S-TAB> to a
" function that will bring up the next or previous buffer in the
" current window, you can put the following into your .vimrc:
"
" let g:miniBufExplMapCTabSwitchBufs = 1
I added that to my .vimrc, restarted a blank Vim, then did the following commands to bring up multiple buffers (and consequently, the MiniBufExplorer):
:e somefile
:e someotherfile
Now, with my cursor inside the file window (not the MiniBufExplorer window), I try CtrlTab and CtrlShiftTab to no effect. Something I missed?

I think this is most likely a conflict with snipMate, which I believe you have since you mention the tab mapping works in select mode. I tried to do it manually map <C-Tab> :bn<cr>,
and it did not work either. I now use map <C-P> :bp<cr> and map <C-N> :bn<cr> to navigate through buffers, and I suppose other mappings would work just as well as long as there is no conflict.

Minibuf explorer shortcuts (may require additional configuration):
[C-TAB] and [C-S-TAB] - move to next and prev buffers
Vim regular buffer shortcuts:
:bn and :bp - move to next and prev buffers
:b# - move to buffer of number #
:h :buffers - for additional help

Did you leave the " at the beginning of the let line? If so, it's commented out, and will not work. Otherwise, you may have a mapping conflict between plugins. The :map command will list current mappings.
It's easier to deal with mappings if you install headlights though.

Related

Renaming a Yakuake session from commandline

Yakuake provides a hotkey and a GUI way to rename commandline tabs/sessions.
I'd like to do the same via the command line, so I can script it and use it in an alias. (My goal is that if I use an alias which does an SSH to some server, then the tab is renamed according to this servers name...)
I tried the suggestions shown here Renaming a Konsole session from commandline after ssh so far no luck.
Since KDE4, one should use qdbus to control KDE apps (instead of deprecated and deleted DCOP).
For example, to change a title of the first session one may use:
qdbus org.kde.yakuake /Sessions/1 org.kde.konsole.Session.setTitle 1 "New title"
To explore available interfaces, methods and properties one may use qdbusviewer.
As a homework try to get a list of active sessions (before you going to change smth).
Like #fgysin pointed out, his command also works for me. BUT it needs the ` character and not " for the subcommand :
qdbus org.kde.yakuake /yakuake/sessions org.kde.yakuake.activeSessionId
It gives :
qdbus org.kde.yakuake /yakuake/tabs org.kde.yakuake.setTabTitle `qdbus org.kde.yakuake /yakuake/sessions org.kde.yakuake.activeSessionId` "NEW TAB TITLE";

How to auto-indent code in the Atom editor?

How do you auto-indent your code in the Atom editor? In other editors you can usually select some code and auto-indent it.
Is there a keyboard shortcut as well?
I found the option in the menu, under Edit > Lines > Auto Indent. It doesn't seem to have a default keymap bound.
You could try to add a key mapping (Atom > Open Your Keymap [on Windows: File > Settings > Keybindings > "your keymap file"]) like this one:
'atom-text-editor':
'cmd-alt-l': 'editor:auto-indent'
It worked for me :)
For Windows:
'atom-text-editor':
'ctrl-alt-l': 'editor:auto-indent'
The accepted answer works, but you have to do a "Select All" first -- every time -- and I'm way too lazy for that.
And it turns out, it's not super trivial -- I figured I'd post this here in an attempt to save like-minded individuals the 30 minutes it takes to track all this down. -- Also note: this approach restores the original selection when it's done (and it happens so fast, you don't even notice the selection was ever changed).
1.) First, add a custom command to your init script (File->Open Your Init Script, then paste this at the bottom):
atom.commands.add 'atom-text-editor', 'custom:reformat', ->
editor = atom.workspace.getActiveTextEditor();
oldRanges = editor.getSelectedBufferRanges();
editor.selectAll();
atom.commands.dispatch(atom.views.getView(editor), 'editor:auto-indent')
editor.setSelectedBufferRanges(oldRanges);
2.) Bind "custom:reformat" to a key (File->Open Your Keymap, then paste this at the bottom):
'atom-text-editor':
'ctrl-alt-d': 'custom:reformat'
3.) Restart Atom (the init.coffee script only runs when atom is first launched).
Package auto-indent exists to apply auto-indent to entire file with this shortcuts :
ctrl+shift+i
or
cmd+shift+i
Package url : https://atom.io/packages/auto-indent
I prefer using atom-beautify, CTRL+ALT+B (in linux, may be in windows also) handles better al kind of formats and it is also customizable per file format.
more details here: https://atom.io/packages/atom-beautify
You can just quickly open up the command palette and do it there
Cmd + Shift + p and search for Editor: Auto Indent:
This works for me:
'atom-workspace atom-text-editor':
'ctrl-alt-a': 'editor:auto-indent'
You have to select all with ctrl-a first.
This is the best help that I found:
https://atom.io/packages/atom-beautify
This package can be installed in Atom and then CTRL+ALT+B solve the problem.
On Linux
(tested in Ununtu KDE)
There is the option in the menu, under Edit > Lines > Auto Indent or press Cmd + Shift + p, search for Editor: Auto Indent by entering just "ai"
Note: In KDE ctrl-alt-l is already globally set for "lock screen" so better use ctrl-alt-i instead.
You can add a key mapping in Atom:
Cmd + Shift + p, search for "Settings View: Show Keybindings"
click on "your keymap file"
Add a section there like this one:
'atom-text-editor':
'ctrl-alt-i': 'editor:auto-indent'
If the indention is not working, it can be a reason, that the file-ending is not recognized by Atom. Add the support for your language then, for example for "Lua" install the package "language-lua".
If a File is not recognized for your language:
open the ~/.atom/config.cson file (by CTRL+SHIFT+p: type ``open config'')
add/edit a customFileTypes section under core for example like the following:
core:
customFileTypes:
"source.lua": [
"conf"
]
"text.html.php": [
"thtml"
]
(You find the languages scope names ("source.lua", "text.html.php"...) in the language package settings see here)
If you have troubles with hotkeys, try to open Key Binding Resolver Window with Cmd + .. It will show you keys you're pressing in the realtime.
For example, Cmd + Shift + ' is actually Cmd + "
You could also try to add a key mapping witch auto select all the code in file and indent it:
'atom-text-editor':
'ctrl-alt-l': 'auto-indent:apply'
I was working on some groovy code, which doesn't auto-format on save. What I did was right-click on the code pane, then chose ESLint Fix. That fixed my indents.
If you are used to the Eclipse IDE or the Netbeans, you can use the package eclipse-keybindings (https://atom.io/packages/eclipse-keybindings):
This Atom package provides Eclipse IDE key mappings for Atom. Currently, the Eclipse shortcuts are directly mapped to existing Atom commands.
To format all lines from a file, just use: Ctrl+Shift+F.
Ctrl+Shift+i worked for me in PHP under Windows ... but some files did not react. Not being the brightest it took me a while to work out that it was the include files that were the problem. If you are using echo(' ... PHP ...') then the PHP does not get re-formatted. To get over this, create a temporary PHP file, say t.php, copy the PHP part into that, reindent it (Ctrl+Shift+i ... did I mention that?) and then copy the newly reformatted PHP back into the original file. Whilst this is a pain, it does give you correctly formatted PHP.

Setting ft=vb causing vim's parenthesis matching to stop working

I'm having a weird issue in which I can't get parentheses to match in VB files in vim or gvim.
For example, if I start vim and insert Iif(test, 0, 1), I can use % to jump between the two parentheses like normal. Then if I run :set ft=vb, it stops working. Actually, I get one more jump, then it stops working.
I have tested this on two different machines running Windows and Linux and I get the same results.
Does anyone know why this might be?
You're using the matchit plugin that comes with Vim. In $VIMRUNTIME/ftplugin/vb.vim, it defines custom pairs (e.g. If...End If) which override the default pairs. To re-enable those (in addition), put the following into ~/.vim/after/ftplugin/vb.vim:
let b:match_words .= ',(:)'
Cp. :help b:match_words.

Keyboard shortcut for going onelevel up in midnight commander [mc]

Is there a keyboard shortcut for going one level up in the directory tree in midnight commander (mc), which will save me from going all the up to the ..?
As shown below - say I'm in a directory that contains tonnes of stuff, and its painful to scroll all the way up. Its clickable, but nothing beats keyboard shortcuts!
If you go to Options->Panel-Options and tick the "Lynx-like motion" option you can use left-arrow to go to the parent directory and right-arrow to enter a directory.
Does Home, Enter count as a keyboard shortcut?
Short answer: No.
Longer answer: Ctrl + PageUp goes to the last diretory - not the parent, but this may be what you want in most cases.
(https://www.midnight-commander.org/ticket/2420)
Without changing the default setup Alt + Y and Alt + U go to previous and next directory in history, which may be enough on most cases (Alt + H to see the full history). If not, you always have Home, Enter.
Alt + Arrows are used to move between windows on byobu/tmux.
To add a custom shortcut (like Backspace) to your user config:
echo 'CdParentSmart = backspace' >> ~/.config/mc/mc.keymap # Globally in /etc/mc/mc.keymap
Here more related handy shortcuts.
In /etc/mc/mc.default.keymap find and uncomment CdParentSmart in [Panel] section. If it's not there, add it. And set a key you want. Behavoir similar to Total/Double Commander would be CdParentSmart = backspace. So it will backspace command line, if it's not empty. Or will level up from any place, if command line is empty.
The file should be edited when MC is not running, as it is resetting it to currently loaded settings on exit.

How do I make elinks dump the web-page at a URL under cursor in a new vim buffer/tab?

I am trying to make elinks dump the web-page at the URL which starts at the current buffer position in vim (and ends at EOL), by mapping this keyboard shortcut and putting it in my .vimrc:
nmap owp :norm yE \| new \| .!elinks -dump #"<CR>
This yanks the rest of the line into the " register. Then it's supposed to open a new buffer and invoke elinks which should dump the rendered web-page into this new buffer. When I run the command the URL gets yanked, and that's it. New buffer does not open and elinks does not get invoked.
What am I doing wrong here?
Is there a smarter way to yank URLs
under the cursor? This method won't
work for URLs which occur in the middle of the line.
Never mind. Dug around in the vim manual and found some workarounds. One problem was with this:
.!elinks -dump #"<CR>
this won't work as expected. Everything after ! operator is passed to the shell verbatim by vim - so the register value will not be passed to elinks. Another problem is that the command separator somehow is not working after :norm yE. The final solution to get around these problems was this:
function! Browser ()
normal yE
new
execute ".!elinks -dump " . #"
set nomodified
endfunction
nmap owp :call Browser ()<CR>
Notice the use of execute to get around the limitation of "!" operator. I still need to figure out a solution for question 2 though.