Copy in insert mode with mouse - clipboard

I'm using vsvim, sometimes I highlight code in insert mode with my mouse and want to copy or cut it out. But I don't know-how. Instead, I have to change back to normal mode, highlight it again then cut it. I tried to Ctrl+O but it would get rid of the highlight. Does anyone know how to solve this?
highlighted text in insert mode

I have not used this extension, but when running vim natively, if you highlight stuff in insert mode, you can right-click and click on copy. Not sure whether this works in Visual Studio. However, reading the docs in GitHub I see there is a vim.handleKeys setting, that you can set in settings.json and you could specify C-c and C-v to be false in order to support Ctrl+c and Ctrl+v natively. The doc provides this example:
"vim.handleKeys": { "<C-f>": false }
which in your case would look like this:
"vim.handleKeys": {
"<C-c>": false,
"<C-d>": false
}

Related

How does one stop VS code from going into normal mode in Vim when doing normal copy `Cmd + c`?

whenever I select code and then do Cmd + c (copy) it then goes by itself to normal mode in vim. So:
How do I stop VS code from doing that?
Why is it doing that?
My default keybinding for copy paste has (go to command pellet type keybinding go to default keybindings):
{ "key": "cmd+c", "command": "execCopy" },
probably this: { "key": "cmd+c", "command": "extension.vim_cmd+c",
"when": "editorTextFocus && vim.active && vim.overrideCopy && vim.use<D-c> && !inDebugRepl" }, except it doesn't let me edit the file!?!?!
I feel the answers are longer than need.
Follow these steps:
Command palette Cmd+shift+P
Type Open Keyboard Shortcuts (not the Json one)
Nice looking file in vscode comes up like pinocchio said (see attached image)
Search cmd+c
Go the the row that has in it's column extension.vim_cmd+c
Click it and then hit backspace (or right click select remove).
Done.
For sake of context see Snippet:
without seeing your exact extension configuration and system info, it's hard to say with certainty, but you may have an extension conflicting with or overriding the default behavior.
open the command palette and type keybindings and choose the command to edit keybindings. you can search for cmd+c to see if anything else is using it, and in what context. alternatively, you can do this directly from your keybindings.json file.
also, for the sake of diagnostic, you can always launch vs code with no extensions enabled just to see if it is indeed an extension problem. if so, you can selectively enable extensions, and when you find the right one, you can look within its internal settings
As Tedskovsky suggested, go to the json file that has the keybinding. Find the last one that maps cmd+c to something. Then remove it. Though, that file can only be opened in read mode so you will need open:
Preferences: Open Keyboard Shortcuts `Cmd+K Cmd+S`
NOT THE JSON ONE (at least not in vscode):
So the first one (not the second one).
That opens a nice looking window that allows you to edit the keyboard settings. Probably the last one in that list I assume. I went to the uneditable one and found the last one and removed it (and yes as Tedskovsky suggested, it was added by the vim extension).
The name of it was:
{ "key": "cmd+c", "command": "extension.vim_cmd+c", "when": "editorTextFocus && vim.active && vim.overrideCopy && vim.use<D-c> && !inDebugRepl" },
search is somewhere in your default editable file to remove it (click and select remove).
Don't select the json file for the keyboard bindings if you want to change it.
Go to settings.json and add this:
"vim.handleKeys":{
"<C-c>": false
}

How to indent my code in codeblocks?

What are the best code blocks short cuts ? Also is there some way we can directly indent all our code ? In addition how can we move through the active tabs in codeblocks ?
Tips about tab identation are helpful when you write your code from begining. But if you paste code in CodeBlocks from some external source, like PDF document, that code often will not have good identation.
In this case, you need to select code, right click on it, and choose Format use AStyle option.
This is a plugin for CodeBlocks for right text formatting.
I hope this will help someone!
You (these are the default settings I believe) can select a block of code and press the Tab key. This will indent the entire block.
So for indenting a whole file: Ctrl + A, then Tab.
In addition, you can use Shift + Tab on a selected block to "unindent"
You can move through the open tabs with Ctrl + Shift + Tab.
As for the best shortcuts:
I like Ctrl + D to duplicate a line and
Ctrl + L to copy it.
Anyway, you can set whatever shortkeys you like in the Editor menu (there you will also be able to find all shortkey currently set).
]2
Add shortcut as you wish from Settings->Editor->Keyboard shortcuts->plugins->Source code formatters(Astyle) or use Plugins->Source code formatters(Astyle)
CTRL+A to select the code and TAB for alignment.
I have not had much luck with the code formatter in C::B. I like my code to look like this...
if (blah..) {
SomeCode();
} else {
DifferentCode();
}
it allows more code to fit on a screen, and is still reasonably readable.
After trying to tweak the settings in Settings->Editor, then Source Formatter tab, when I went to format my code, it removed the if line entirely, and I have not been able to unset my tweaks to make it work.
Fornatually, ctrl-z still works.
The code formatter should never remove code, only play with white space.
Maybe there is a better plugin.
Mark.
In addition in How to switch between tabs in codeblocks.
codebocks 20.03
Linux (KDE Neon)
To switch between tabs.
Activate this with CTRL+SHIFT+TAB, then you can use the know options:
CTRL+TAB , to switch to the right tab.
CTRL+SHIFT+TAB , to switch to the left tab.
Or this other option, but this is not in the keyboard shortcuts, this option doesn't work in a cycle mode, when your get the last right tab, it jump to the bottom tabs:
CTRL+ right-arrow-key , to switch to the right tab.
CTRL+ left-arrow-key , to switch to the left tab.
Remember to activate with CTRL+SHIFT+TAB.
After you land in the desire tab you can type TAB to begin to start writing code.

Keyboard-only column block selection in GVim Win32, or why does Ctrl-Q not emulate Ctrl-V when mswin.vim is included?

I want to be able to select columnar blocks using only the keyboard when I use GVim on Windows, but I do not seem to be able to do so when using gvim (7.2) on Windows XP. Edit: For convenience, it is preferable to make the selection with arrow keys as is commonly done in other versions of vi/vim.
In a terminal, when using vim, to define a block, one may select columnar blocks by pressing Ctrl-V and by conveniently moving the cursor with the arrow keys.
When using GVim on mswin, Ctrl-V is mapped to a paste operation. Every reference found on this topic mentions that on mswin, Ctrl-Q is set to act the same way that Ctrl-V works on other platforms, but this does not work for me.
After research indicated that the Ctrl-Q behavior is implemented through the inclusion of mswin.vim, it seemed that perhaps mswin.vim was not being loaded by GVim. mswin.vim is apparently loaded via _vimrc. It seemed that perhaps mswin.vim was not loading, so perhaps _vimrc was not setup correctly, but...
C:\Program Files\Vim\_vimrc exists contains:
source $VIMRUNTIME/mswin.vim
behave mswin
C:\Program Files\Vim\vim72\mswin.vim exists and contains:
" Use CTRL-Q to do what CTRL-V used to do
noremap <C-Q> <C-V>
C:\Program Files\Vim\_vimrc should load since Edit | Settings Window in the GVim graphical menu loads this file for editing, and it is clear that C:\Program Files\Vim\vim72\mswin.vim is loading because one can insert a syntax error in that file and GVim will complain about it when it starts up (it was backed it up for testing and restored to prevent accidental corruption).
When Ctrl-Q is pressed, the cursor changes in the same way that it changes when you block select text using the mouse, but any cursor movement at this point causes the cursor to change back to a normal cursor. It does not matter whether one continues to hold Ctrl, Ctrl-Q, or not.
Edit: Ctrl-Q enters block selection mode as indicated by the cursor change since other cursor movement commands extend the block, however, the original intent of this question was to learn how to use the arrow keys (in the same manner that they are able to be used in other implementations of the editor) though this was not explicitly stated in the original, unanswered revisions of the question.
It is possible to visually select columnar blocks by pressing Alt while holding down the left-mouse button, but Alt during arrow key motion after pressing Ctrl-Q also does not work.
Research also seemed to indicate that pressing v in command-mode would enter visual-mode, and that perhaps this was relevant, but using this does not seem to help the situation.
C:\Program Files\Vim\vimfiles does not contain anything except an empty directory structure. C:\Documents and Settings\username does not contain vim configuration files, nor does C:\Documents and Settings\username\My Documents. Other C:\Documents and Settings\username locations, where application-specific or local settings are commonly stored, also appear not to have vim settings. The same is true for %HOMEDRIVE% and for the environment variables.
One way to visually select column blocks in GVim on Win32 using only the keyboard is to press Ctrl-Q, release it, then press and hold down the Shift key while using the arrow keys to select the column block.
Why Ctrl-Q columnar selection behaves this way is not known, but it does not really matter since the goal was to select column blocks using only the keyboard. In Vim, Shift is not used when using Ctrl-V to select blocks.
:help mswin does not mention this nuance of the CTRL-V alternative.
The best thing to do is to remove these lines from your vimrc. They are totally unecessary and change too many basic Vim features.
The noremap <C-Q> <C-V> in mswin.vim remaps the original command to Ctrl + Q.
If mswin.vim is included, after pressing Ctrl + Q, the indicated mode should switch to Visual Block, and any movement (e.g. j, l, w) extends the visual selection. If that doesn't work for you, you may have something interfering.
Are those movement commands itself remapped, or is there an autocmd on CursorMoved?! Try disabling your plugins (vim --noplugin) and most parts of your .vimrc.
Note that cursor keys do not normally constitute proper movement (and their use in Vim is frowned upon).
What you perceive as the right (and only) way to extend the selection (with shifted cursor keys) is just a consequence of :set selectmode=key, as done by :behave mswin.

VS2010 Debugging: Display Datatip w/o mouseover (use keyboard)?

I'm in VS2010, on a breakpoint. How can I cause a datatip to be displayed for a given variable/expression w/o using my mouse to hover it?
That can't be done, exactly, but you can get the same result by selecting the variable you want to watch (using ReSharper's Ctrl + Alt + →/← can speed this up), and pressing Shift + F9, which will raise "QuickWatch" modal window with the datatip contained within.
If you prefer, you can also go into Options->Keyboard and bind the Debug.AddWatch to a different keyboard shortcut, and use that instead of Shift + F9, and then your variable data will persist in the Watch window so you can come back to it later (as suggested here)
You can also do this by opening the command window (Ctrl + Alt + A) and typing Debug.AddWatch variable_name.
While you can pin multiple windows in VS it will be a somewhat cumbersome experience and you will have to over it.
I personally use visual studio plugin called Oz Code, that automatically annotates all the local variables and intermediate results so I don't have to chose which variables to pinpoint.
The results looks something like this:
Will adding a watch not be suitable? When you hit your breakpoint the relevant details of the variable will be shown in the watch window.
Perhaps I have misunderstood what you're trying to achieve here!
You can click the 'pin' icon to force any datatip to stay open, and it will update to the current contents when you hit the breakpoint.
I don't know of a way to open a specified tip without pinning it, however.
The Locals and Autos windows might be helpful as they show all local variables, (they even show the return value of called functions!).
Note however that they show directly only variables in scope, so if you need a detail property that it is not yet menotioned in the code you can drilldown using the →/← keys, however if it is already mentioned in the code in the current scope then you should be able to see it directly in the Autos window.

Textmate tab and de-tab selected block

Recently switched to Textmate on Mac for coding. On PC when ever I want to tab in or out a block of code I just highlight and press tab or shift+tab to move it in our out. It's very useful when you are adding an extra loop or conditional statement to a block of code to keep everything tidy and neatly indented.
On Textmate however when I try this it just replaces my selected text with a tab. So is there a way to do tab and de-tab lines of code in textmate?
Indent: Alt+Tab
Un-Indent: Shift+Alt+Tab
the hotkey is command-left bracket to move left and command-right bracket to move right
(the buttons next to 'p')
heres a link to more hotkeys and such
http://projects.serenity.de/textmate/tutorials/basics/
You can use Shift+Tab to decrease indent; You just need to make and assign a macro. You can reuse this technique to accomplish a great many things.
Enter some text, and intend them, this is mostly for feedback.
Click the Record Macro Button
Use ⇧+⌥+⇥ (aka; Shift + Option + Tab) to decrease the indentation.
Click the record button to stop recording the macro.
Use the Edit menu or ⌃+⌘+M to save your macro;
Saving will prompt you to create a new bundle*, or add your macro to an existing bundle.
Add a Key Equivalent by clicking in the field and pressing ⇧+⇥
Your bundle-macro should look like the one below, simply Save and you're done! TextMate will now decrease indent on ⇧+⇥
*: (as noted by u/PatrickT) Sadly the create new bundle functionality has not yet been implemented, and you must choose to add to an existing bundle. You can still create a bundle via Bundles -> Edit Bundles then Command + N.
As an alternative, you can change the keybindings, see Link
Here is what I did:
Install Link
Go to File -> Open -> User Key Bindings, this will create/edit ~/Libary/KeyBindings/DefaultKeyBinding.dict
Add a binding, for the action enter shiftRight: (indent) manually (this is a TextMate specific action and not in the pre-populated actions list)
Choose a shortcut, I used cmd+alt+right
Do the same for the action shiftLeft: (un-indent, I used cmd+alt+left)
Save and then restart TextMate
I used a shortcut with arrow keys as my right hand is already on the arrow keys when I am selecting multiple lines, so this is a good fit.
The reason why I did it was because I have a german keyboard and alt+tab/alt+shift+tab don't work for me since I am using Witch for app-switching using these exact shortcuts.
EDIT: cmd+alt+left/right don't work when you have multiple tabs open, as they are used for navigate to next or previous tab in TextMate... seems this cannot be changed or overridden (I tried Setting Shortcut Keys in Textmate). Looking for an alternative shortcut now.

Resources