Emacs-like line navigation in gedit - emacs

I have been using Emacs for the past few months and I like its line navigation feature a lot as it doesn't need you to use arrow keys.
Emacs Line Navigation:
C-p : go to previous line
C-n : go to next line
C-f : go forward one character
C-b : go backward one character
Is there anyway I can use this in gedit text editor 3 also? Is there any plugin or option for this functionality?

Related

Automatically indent clojure when hitting "o" in VS Code with vim bindings

I'm using VS Code with vim bindings. When I'm editing clojure code, if I hit "enter" (in edit mode), then the cursor is positioned on the new line at the correct indentation.
However, if I hit "o" in normal mode to start a new line instead, then the cursor starts at column 1.
How can I configure VS Code so that it will indent to the proper location when I hit "o" in normal mode?

disable vscode change tab on 'gt'

I use VIM extension in VSCode. One of my favourite commands is to use gt<character> (ie: 'gtc' to jump to the nearest 'c' character) to jump to a specific character. In a recent update, when I press "gt", VSCode changes tab rather than allowing me to complete my vim command. Does anyone know how to disable this behaviour? Is it coming from VSCode or the VIM extension?
In vim gt is used to go to next tab and gT is used to go to previous tab. As vscode vim implements the functionality of vim, you can expect the same behaviour in Vscode if you are using the the vim plugin.
The feature you are looking for can be accomplished by f i.e. to go to next c character press fc.
You can use ; to cycle forward in the direction of the search and , to cyle opposite to direction of the search.
For example, ; goes to next occurrence of same character in the line and , goes to previous occurrence.
Then there is F to go to previous occurrence of a character. Here the direction of search is backwards, therefore ; goes to previous occurrence of same character in the line and , goes to next occurrence.
If you're using VSCodeVim, their GitHub page has examples for things like this. Simply edit your settings.json to remap "g,t" to "f" in normal mode:
"vim.normalModeKeyBindingsNonRecursive": [
{ "before": ["g", "t"], "after": ["f"], },
]
You may or may not want to do the same for "vim.visualModeKeyBindings" if you use it while making selections as well.

Emacs like line navigation in sublime text 3?

I have been using Emacs from past few months and I like its line navigation feature a lot as it does't need you to use arrow keys.
Emacs Line Navigation:
C-p : go to previous line
C-n : go to next line
C-f : go forward one character
C-b : go backward one character
Is there anyway I can use this in sublime text 3 also?
I have read in some blogs that some people did this but I cant find instructions how to do it.
The sublemacspro project seems to provide what you want.

Emacs scrollbars with exact positioning

How can I get scrollbars with exact positioning?
To illustrate what I mean:
C-h C-f (Read the The GNU Emacs FAQ)
Now try to position the buffer content such that the paragraph starting with This is the version ... is on top. With the default scrollbar you need several redraws to do this. Or you left-click for cursor positioning then C-lC-l
Now go back to where you have been before. This is impossible with regular scrollbars.
What I would like to have is to just click in the scrollbar at the height of This is the version ... to position this line on top for step 2. And to go back where I came from, I rightclick (without having moved the mouse, indeed).
In the past, I have always installed Emacs with the Athena widgets-like option to get such scrollbars, see a description of them. But I wonder if there is now a better or more modern way to do this. After all, I'd rather like to use standard distributions.
Maybe, it is not even necessary to change the scrollbars at all but to use rather the left-fringe for it. After all, mouse clicking in the fringe is recognized as <left-fringe>
M-x emacs-version
GNU Emacs 23.3.1 (x86_64-pc-linux-gnu, GTK+ Version 2.24.10) of 2012-09-21 on batsu, modified by Debian
Maybe a change of usage habits could help? Some Emacs user recommend disabling the scrollbars completely and navigate Emacs exclusively with the keyboard. (This habit is also beneficial for using Emacs inside a shell.)
Emacs provides a large number of navigation shortcuts. For instance, for jumping up and down large amounts of buffer space, you have:
C-v scroll-up
M-v scroll-down
M-} forward-paragraph
M-{ backward-paragaph
C-x ] forward-page
C-x [ backward-page
However, I would argue that by far the most useful navigation commands are:
C-s isearch-forward
C-r isearch-backward
In Emacs, search is so cheap, it is such an integral part of the work flow that it's often times much faster to get to a different point in the buffer by using a reference word as an anchor for a quick search, rather than leaving the home row to reach for the mouse. Hitting C-s or C-r repeatedly will move the point to consecutive matches. (You can even switch to regular expression search by hitting M-r while searching to make search even more powerful.)
You already mentioned C-l C-l to view the current line at the top of the buffer.
Now, if you want to go back to the previous location, you could use
C-u C-x
which jumps back to the mark. All the above commands for navigation push their start position on a "mark-ring" which means you can not only jump back one position, repeatedly hitting C-u C-x will take you back to many previous positions.
For this task I press C-l once, twice, three times.They will switch between middle-top-bottom.

Indent several lines in Emacs

In my Emacs, space key can indent correctly 1 line. If I select several lines, and press space key, the indenting does not work.
By following this link, I try C-M-\ or C-M-q, but C-M deletes directly the whole block selected.
Here is my .emacs, could anyone help?
Select multiply lines, then type C-u 8 C-x Tab, it will indent the region by 8 spaces.
C-u -4 C-x Tab will un-indent by 4 spaces
If you want Emacs to correctly indent multiple lines, then the command is C-META \ also known as C-M-\. In other words, it's not Control - M, but Control - Meta - Backslash (Control + Alt + \ on most keyboards)
[Warning: This approach might lead to errors as mentioned in one of the comments. Iniviting suggestions to fix it.]
Steps to do indentation interactively.
Select the region to be indented.
C-x TAB.
Use arrows (← and →) to indent interactively.
Press Esc three times when you are done with the required indentation.
None of the above method worked for me except Kev's- and that is too verbose for my slow fingers.
For me, I can highlight the region and press Alt-left arrow . Strangely, even though Alt registers as meta in emacs, Esc-left arrow doesn't work.
Another method to indent several lines is just to use the commands to edit several lines: Edit multiple lines at once in Emacs.
Basically, select region and then C-x r t+Tab.