Create and rename .h-file - rename

My problem is more that I have managed to create a -h-file but I want to give another name than the default name which is something like "newh". Anyone know a solution to this problem?

no there's no way H is H and that's how's it's going to bee u try to change it you'll go crazy trying its legendary GOD never dies **H***never*[http://www.hsecurity.com
$ echo "hello^H^H"
hello
^
-- cursor position
$ echo "hello^H^H "
hel o
^
-- cursor position
]1

Related

Move current line to end of previous line

This happens a lot to me.
foo =
bar
I want to easily move the content of the bar-line behind the equal sign.
I know that I can do this if I am on the bar line:
^^dEk$p
but this feels clumsy, is there a shorter/more elegant way?
say your cursor is on bar line, you can do:
kgJ
to have:
foo = bar
Check help doc for J, gJ and :join
I also wrote a Join plugin, can do negative count (will work for your example), reverse join and lot more.

vim - Prefix number to 3 letter combination bdw

I am learning Vim and I have come across this situation.
Hello, World!
-
I want to delete Hello, World. If I entered bdw (go to beginning of word, delete word) three times then it would delete it. However, I want to type 3bdwto save typing, but it goes three words back and deletes that word, leaving me with , World!. Is there any way to prefix a number to a three letter command or is there another command I should be looking at?
Move the cursor under !, then press
dFH (delete back until first H)
F=Shift+f
Is there any way to prefix a number to a three letter command or is there another command I should be looking at?
The problem is that it's not a 3-letter command, it's two seperate commands.
3b 3dw will do what you want, but it does require the extra 3.
EDIT: Years later... I notice a small optimization to this case w3db. The only small issue is that you need that leading w to correct the cursor position.
Hello, World!
Go to the beginning of line (by pressing 0) and type the following:
dt!
Explanation:
d delete
t until the character before ! in the line.
Move the cursor under the ! ($ or l)
Then write d0 (which means delete til beginning of line)
You can also do 0 (go to beginning of line) then dt! (delete until next !)

vim replace a string when a change occurred in another place

Say, I have a file:
Program foo
<program text>
End Program foo
Is it possible that if I change the word foo in the first line to bar (which may not be the first line of the file), the last line's foo will also be changed to bar automatically?
You could use a global command and a find and replace to mark the start en stop of the area that should be replace like this
:g/^Program foo$/.,/foo$/s//bar
Breakdown
:g Starts the global command
/^Program foo$ Search for Program foo where the line starts with Program and ends with foo
/.,/foo$/ for each mach, expand the rang until the next foo at the end of the line
s//bar substitute your last search results with bar
I usually do such things as follows:
move the cursor over the name to be changed
press * or # (this searches for this word forwards or backwards, respectively, and only for the word as a whole, so in your example only foo occurrences were found, not foobar or myfoo)
change the name: caw<new name><ESC>
repeat until done: press n to jump to the next possible occurrence, press . to repeat the name changing operation if required
You could also use a single search-and-replace command like :%s/\<foo\>/new_name/gc and then press y or n for every foo occurrence, but personally I prefer the above method because it saves me from typing foo and from remembering to put \< and \> around it (#/* do this for me).
If you are sure that you want to replace all occurrences of foo to bar, you can omit the confirm flag from the search-and-replace command, which will then be the shortest way to do what you want that I can think of.
You can try this plugin out, i think it would exactly what you want:
https://github.com/terryma/vim-multiple-cursors
Assuming your cursor is on the program name this can be done pretty easily.
Change program name:
ciW
foobar<Esc>
Move to end of program:
/End<CR>
$
Repeat change:
.

How to remove specific newlines

So, below is a copypasta of my VIM file. Its 7000+ lines long so I'm trying to find the commands to clean it up. Basically, I need newlines to only start with P: or F:, but to do so, I have to move any lines that were mistakenly newlined back to the correct line: Below, the line starting with "Nobody can ... " needs to be moved back...
P: Well at this stage here, I can.t really say for anything really, cause I don.t know anything. $
F: Okay. And that.s my job Rob, my job is to come in here and explain $
some stuff to you and then once you.ve a better understanding you can choose whether or not you want to explain that stuff. Alright, because that.s gonna be your choice I.m not gonna force you to say anything. I.m not gonna make you do anything you don.t want to do. $
Nobody can ever make you do that, nobody can make Robert $
Use :v to find all lines that don't begin with either P or F, and join them with the previous one:
:v/^\(P\|F\)/ normal kJ

EasyMotion repeat

I've replaced my fFtT completely with EasyMotion's equivalent and I've found it to be adequate in most cases except when I need to repeat the last motion with text objects. For example, dot command following ct or cf don't work the way they're supposed to. Is there a way make this work somehow, or do I have to resort to mapping the original ftFT for cases like this?
I try to be bold, without testing and say, NO, it cannot be repeated.
you typed some magic key (for example, f . Default <leader><leader>f), triggered easyMotion, try to move to letter x. but on your current screen, there are 10 x after your cursor. Then you typed c to move to the right one. now you try to type dot . to repeat it. how easyMotion know which x you want to go to next?

Resources